Compare commits
1089 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
637a878808 | ||
|
|
999c3d7ebe | ||
|
|
8a8f545656 | ||
|
|
ce6b120f23 | ||
|
|
3651bf0e1d | ||
|
|
2e261aab4b | ||
|
|
5d76781965 | ||
|
|
bf44d2b733 | ||
|
|
c8e1500892 | ||
|
|
4e1c338bec | ||
|
|
e3fdcd179a | ||
|
|
b4c5df3616 | ||
|
|
505e347939 | ||
|
|
1380b581bc | ||
|
|
f99ef659e0 | ||
|
|
829c546a52 | ||
|
|
f520b3e2e0 | ||
|
|
f74945fab9 | ||
|
|
88f6e70fc8 | ||
|
|
200cefcfb3 | ||
|
|
d5bea30024 | ||
|
|
a9e521eaf2 | ||
|
|
2055c4bb3b | ||
|
|
e0b26ea5b8 | ||
|
|
1f779012a2 | ||
|
|
2df383a788 | ||
|
|
1f40c96cfe | ||
|
|
2b9135903b | ||
|
|
7660eeca92 | ||
|
|
a6bee06006 | ||
|
|
3cb005011c | ||
|
|
93aaf0f58a | ||
|
|
ab090a9fee | ||
|
|
d70f73b541 | ||
|
|
810eefd386 | ||
|
|
3251816066 | ||
|
|
90ff64452a | ||
|
|
544e64dc29 | ||
|
|
8f590d0239 | ||
|
|
6cc389cd0f | ||
|
|
4ae054de73 | ||
|
|
53abbb82d6 | ||
|
|
7eb06a41ae | ||
|
|
1186935d7d | ||
|
|
f3b7e22f23 | ||
|
|
8613ac0861 | ||
|
|
fa87217b90 | ||
|
|
2a0d749ef5 | ||
|
|
2151ea27a9 | ||
|
|
cffad3c660 | ||
|
|
e7e7729715 | ||
|
|
de98b0f88a | ||
|
|
1565ed626b | ||
|
|
df9e1ae124 | ||
|
|
42360e124f | ||
|
|
3bbd241264 | ||
|
|
10b7aa3bc7 | ||
|
|
2e3b7d31ca | ||
|
|
a077b5b8d2 | ||
|
|
c17fe6022f | ||
|
|
27c870ff4d | ||
|
|
28aea06a4c | ||
|
|
5530ab4d01 | ||
|
|
e3fedfdcd2 | ||
|
|
2de089f09a | ||
|
|
eee469ca48 | ||
|
|
0a9699d764 | ||
|
|
6e4d330d35 | ||
|
|
113212b1dd | ||
|
|
680c2030ec | ||
|
|
e0c1a93d66 | ||
|
|
e17e9db240 | ||
|
|
a3b8183585 | ||
|
|
3f5ad2d1ff | ||
|
|
774e7c2579 | ||
|
|
c19efa359e | ||
|
|
1439e701ac | ||
|
|
3ff6d7bd8b | ||
|
|
ca1f95297c | ||
|
|
a83617e477 | ||
|
|
5cd7764c6e | ||
|
|
31ca7605c8 | ||
|
|
d19d4573b9 | ||
|
|
0c52053739 | ||
|
|
ca6df068a6 | ||
|
|
46868e633c | ||
|
|
54a6939d0b | ||
|
|
601e146ba9 | ||
|
|
f95d55a8d2 | ||
|
|
b2b52b336c | ||
|
|
6a04c366bf | ||
|
|
2e904f3719 | ||
|
|
06b225aff3 | ||
|
|
5278ba7739 | ||
|
|
3db704f235 | ||
|
|
1ed5e7e259 | ||
|
|
5ce817e327 | ||
|
|
be829b7399 | ||
|
|
c8b9eb7eff | ||
|
|
a7232b6d3b | ||
|
|
f41547f7b7 | ||
|
|
09806185d8 | ||
|
|
10d7ed2a2c | ||
|
|
27da0e4c57 | ||
|
|
69ad23a7dd | ||
|
|
fdc2736012 | ||
|
|
ff968cbdcf | ||
|
|
20f11b0c4e | ||
|
|
1469168f90 | ||
|
|
3fb979009b | ||
|
|
1c3eadf096 | ||
|
|
a29a10152a | ||
|
|
0f781849b4 | ||
|
|
3c4ffc3599 | ||
|
|
7c2a2bbea1 | ||
|
|
17ff0169b8 | ||
|
|
82eba6b49c | ||
|
|
1c76565c02 | ||
|
|
764f22b32c | ||
|
|
08f8c08c4d | ||
|
|
a067a9ad92 | ||
|
|
ad54650303 | ||
|
|
765517013c | ||
|
|
fec4011989 | ||
|
|
92ec3f3b1f | ||
|
|
57ac67e874 | ||
|
|
0efcc40b09 | ||
|
|
71234f6b48 | ||
|
|
078ca7e9b2 | ||
|
|
44e0edc404 | ||
|
|
f27a3ee5e2 | ||
|
|
2be3fb329e | ||
|
|
944166496e | ||
|
|
5f1bf89743 | ||
|
|
5f3f974d3e | ||
|
|
ff7ae26ce5 | ||
|
|
a376e4b90d | ||
|
|
fc1cc16de6 | ||
|
|
ca27491d14 | ||
|
|
ed419d5a4d | ||
|
|
9e2b93b6cd | ||
|
|
f9913ead46 | ||
|
|
70dfb81139 | ||
|
|
4b9c783b9a | ||
|
|
d626fcf12d | ||
|
|
958ab4686d | ||
|
|
9fee44b6fd | ||
|
|
56b0774eb5 | ||
|
|
f91749c17f | ||
|
|
98a52a7559 | ||
|
|
49334fdb4c | ||
|
|
b081865c17 | ||
|
|
7863aa3f56 | ||
|
|
9a05bc9145 | ||
|
|
6d1c31066e | ||
|
|
59e117ad7c | ||
|
|
9ebe42830f | ||
|
|
be1d4be19e | ||
|
|
c0c154e895 | ||
|
|
a39558cac2 | ||
|
|
84c1e6806c | ||
|
|
65a8cb72cb | ||
|
|
a0c528d299 | ||
|
|
b4bac4ea17 | ||
|
|
b42b66bc8f | ||
|
|
4f934b5bf0 | ||
|
|
be3dbf920d | ||
|
|
49773cf84e | ||
|
|
6f4f89b0fb | ||
|
|
8dca771cca | ||
|
|
348f66c247 | ||
|
|
065a037234 | ||
|
|
82b3bad6a0 | ||
|
|
8ffd05496a | ||
|
|
e15f83f913 | ||
|
|
aedff383c6 | ||
|
|
942f9f93b4 | ||
|
|
d78f392625 | ||
|
|
4b41b34833 | ||
|
|
1bb18dfc46 | ||
|
|
24b4c31037 | ||
|
|
47bac8d2d9 | ||
|
|
4ee80fafea | ||
|
|
8a4c145048 | ||
|
|
9abe9a3a2c | ||
|
|
3167b67693 | ||
|
|
c88f32cea3 | ||
|
|
62b5f16fdb | ||
|
|
895774141e | ||
|
|
7720269bdc | ||
|
|
96129c6e31 | ||
|
|
22e81eb28a | ||
|
|
bb830de073 | ||
|
|
b3bc7a22c4 | ||
|
|
caf21632de | ||
|
|
192c922cbc | ||
|
|
ef8af52e53 | ||
|
|
45ba9ccc7a | ||
|
|
2deef73518 | ||
|
|
8193186dcd | ||
|
|
836947df64 | ||
|
|
00147fe136 | ||
|
|
203affee16 | ||
|
|
6a115c5b9b | ||
|
|
edcd9c6ffb | ||
|
|
599430d88a | ||
|
|
4874f93056 | ||
|
|
f207641021 | ||
|
|
d8664534e4 | ||
|
|
b60ab910d7 | ||
|
|
2ccef476ea | ||
|
|
0c3b2239c1 | ||
|
|
966d98c732 | ||
|
|
55b9e629cd | ||
|
|
914eff9a1f | ||
|
|
43f8d0e623 | ||
|
|
d8a223e360 | ||
|
|
c75d1a66c5 | ||
|
|
2ca0df3f40 | ||
|
|
c92f7c9955 | ||
|
|
9161338c9f | ||
|
|
be84e7c384 | ||
|
|
2ba2117f2a | ||
|
|
21b0927c53 | ||
|
|
c3f43c899f | ||
|
|
d974a2ff1d | ||
|
|
57d94f82ed | ||
|
|
3200ebd799 | ||
|
|
2babd47866 | ||
|
|
a478fee735 | ||
|
|
6c05e98c6e | ||
|
|
283c53b343 | ||
|
|
25e5e0f38d | ||
|
|
cc8b1a6fc0 | ||
|
|
722997a64b | ||
|
|
bab030bf39 | ||
|
|
6fdec929f5 | ||
|
|
dc55a9e747 | ||
|
|
308801a465 | ||
|
|
e7b8c7a510 | ||
|
|
f57cea0164 | ||
|
|
559e5ab7fa | ||
|
|
136acd2b32 | ||
|
|
dd96cf4180 | ||
|
|
718b9991c1 | ||
|
|
c219086e7e | ||
|
|
80e8bbcda8 | ||
|
|
14a1403936 | ||
|
|
947682cf88 | ||
|
|
c0093bf58d | ||
|
|
1b320f1dd5 | ||
|
|
9ba24e16c3 | ||
|
|
4fd10a3fcc | ||
|
|
0bb84957f0 | ||
|
|
f83be684f6 | ||
|
|
eedbe38535 | ||
|
|
e95886f47d | ||
|
|
eaab50c8b2 | ||
|
|
40ab9dc95d | ||
|
|
17d45a0ea1 | ||
|
|
aee9586fd5 | ||
|
|
c94ee61690 | ||
| 86d0619e9e | |||
| 85e5ae4a27 | |||
|
|
df5b862b36 | ||
|
|
3333e9b343 | ||
|
|
265a1b91e6 | ||
|
|
4f5aeb4abb | ||
|
|
1cf28423bb | ||
|
|
831857418b | ||
|
|
8303af4e32 | ||
|
|
9651e0344d | ||
|
|
d2fef3a336 | ||
|
|
27bbaf83d2 | ||
|
|
d276510301 | ||
|
|
ebb09f2cf0 | ||
|
|
eeb48fa769 | ||
|
|
ae0dfd4cf4 | ||
|
|
dc6db2db8e | ||
|
|
027ffa19ca | ||
|
|
949b070f03 | ||
|
|
80c380ce7a | ||
|
|
d4529675f0 | ||
|
|
10569b34f8 | ||
|
|
1600a275be | ||
|
|
817d44a693 | ||
|
|
2e28867bc7 | ||
|
|
48e4753a2a | ||
|
|
5595fd5ad9 | ||
|
|
65a530b33b | ||
|
|
25730745b8 | ||
|
|
8350944f7a | ||
|
|
9dfcd9091b | ||
|
|
b0cf2fbe62 | ||
|
|
2812fa1f08 | ||
|
|
7cc14319ee | ||
|
|
9476a98b69 | ||
|
|
b393bd17b8 | ||
|
|
24fec9b4a7 | ||
|
|
5128d2b100 | ||
|
|
0830cc75e8 | ||
|
|
13da7ceafc | ||
|
|
ca1f6fccbe | ||
|
|
5984d5a475 | ||
|
|
7176f00b9d | ||
|
|
6ddcd52c20 | ||
|
|
5f91a82539 | ||
|
|
bd03bebf66 | ||
|
|
3e7800551a | ||
|
|
84e54bf4d7 | ||
|
|
2451d1ca29 | ||
|
|
bc1e059d32 | ||
|
|
9286e28acc | ||
|
|
fb90a96f65 | ||
|
|
f1761fa154 | ||
|
|
61a994023d | ||
|
|
e8deb61cad | ||
|
|
89b30a3830 | ||
|
|
48b46da333 | ||
|
|
d294481d5a | ||
|
|
f328d74b38 | ||
|
|
3af95bd88f | ||
|
|
8f9e334e0b | ||
|
|
f3848a6a65 | ||
|
|
bb49c91799 | ||
|
|
efeb2ac31d | ||
|
|
e1905cfccc | ||
|
|
c73f22ab60 | ||
|
|
8b6349c187 | ||
|
|
ced6ba0951 | ||
|
|
96adca6623 | ||
|
|
e0e5cbdae5 | ||
|
|
e754065a5d | ||
|
|
b3ced58e91 | ||
|
|
33f0594a6e | ||
|
|
263c155acb | ||
|
|
9da4fd8d2f | ||
|
|
5040922b5d | ||
|
|
fd6ef8aaa3 | ||
|
|
c172e726d4 | ||
|
|
beee8def03 | ||
|
|
df9b60c921 | ||
|
|
f250957e0f | ||
|
|
2867386ea1 | ||
|
|
f9e1bb21af | ||
|
|
090369c02e | ||
|
|
6310f7b494 | ||
|
|
97baf97d97 | ||
|
|
5eff50358a | ||
|
|
f102b2753c | ||
|
|
3dd5cf5910 | ||
|
|
dd9b616371 | ||
|
|
766a35d2f3 | ||
|
|
8cd0816719 | ||
|
|
d7c472372e | ||
|
|
a73dfb6527 | ||
|
|
0494432fa1 | ||
|
|
2176e32aec | ||
|
|
ff0ac93af1 | ||
|
|
a243efcd74 | ||
|
|
74212b0456 | ||
|
|
74c36d2691 | ||
|
|
2d20a2b5c7 | ||
|
|
b78d5c4ca2 | ||
|
|
a3b888c2c5 | ||
|
|
92ef9b145f | ||
|
|
31cb674994 | ||
|
|
618f83ba52 | ||
|
|
6bea930477 | ||
|
|
63f96ca426 | ||
|
|
302ff68ab6 | ||
|
|
c2fe05bd5d | ||
|
|
f03a46a0da | ||
|
|
7e7859c45e | ||
|
|
cbc471ac93 | ||
|
|
c06d648a04 | ||
|
|
c457f143b3 | ||
|
|
0901922618 | ||
|
|
a1a080b68e | ||
|
|
9baac98681 | ||
|
|
ad062f5355 | ||
|
|
3ab6fd6b21 | ||
|
|
6eaf2b37c9 | ||
|
|
37337b9611 | ||
|
|
bfdc340a77 | ||
|
|
bc6ec1e498 | ||
|
|
0d27fb7bd5 | ||
|
|
396d123b4f | ||
|
|
c705214b94 | ||
|
|
adbc9d83b2 | ||
|
|
59085a5b13 | ||
|
|
7dbfd75944 | ||
|
|
6c625c4592 | ||
|
|
2b948d7d35 | ||
|
|
979769669f | ||
|
|
9a9be62928 | ||
|
|
b21b94beca | ||
|
|
78796da29a | ||
|
|
f98f900550 | ||
|
|
5213725aeb | ||
|
|
648f0c8b18 | ||
|
|
65a96e5dfb | ||
|
|
03d3b5a581 | ||
|
|
e9225a2a2f | ||
|
|
e9f9a68c61 | ||
|
|
edd7949cf4 | ||
|
|
577823a804 | ||
|
|
07ae683b22 | ||
|
|
23165bd5d2 | ||
|
|
e11b4f4611 | ||
|
|
4bbf80c7a4 | ||
|
|
990101655e | ||
|
|
a47113288b | ||
|
|
64178e8bdf | ||
|
|
46c422aee5 | ||
|
|
6b327a830a | ||
|
|
6b4e3d4e5e | ||
|
|
b06bccd277 | ||
|
|
334eaef18e | ||
|
|
5e2c0e035e | ||
|
|
9a8abf0a60 | ||
|
|
0a435db932 | ||
|
|
10653b50c5 | ||
|
|
c5e0474fd6 | ||
|
|
5933a585cd | ||
|
|
714d618550 | ||
|
|
24341f5d1c | ||
|
|
16fa4f09ed | ||
|
|
7476e9a721 | ||
|
|
63f3fbadad | ||
|
|
5a75d81980 | ||
|
|
2f184ee50a | ||
|
|
7fccdd507b | ||
|
|
2c765f7547 | ||
|
|
8c2e0ab70f | ||
|
|
9b18e6c175 | ||
|
|
db8da30d67 | ||
|
|
07e21a6dec | ||
|
|
fc56434e55 | ||
|
|
c7ef385ba0 | ||
|
|
cb72da4031 | ||
|
|
6ce9c708dc | ||
|
|
7036c87d09 | ||
|
|
d02fc8f93b | ||
|
|
e7d6da9e1d | ||
|
|
c3dcae9427 | ||
|
|
2d008b822a | ||
|
|
f077bf4283 | ||
|
|
d5848e415c | ||
|
|
9d0d0f5e21 | ||
|
|
de5bff6892 | ||
|
|
43242124c0 | ||
|
|
2f02aef723 | ||
|
|
b5fe22f908 | ||
|
|
660c30602c | ||
|
|
b7e26a3843 | ||
|
|
a7315ffa36 | ||
|
|
c95ff61c20 | ||
|
|
69cead265b | ||
|
|
73cdbb1426 | ||
|
|
f2e9fef592 | ||
|
|
a4c1c1dc75 | ||
|
|
2a73940961 | ||
|
|
6a06a29e54 | ||
|
|
e8eac75f71 | ||
|
|
2d5c6c2090 | ||
|
|
5b8ee36a6e | ||
|
|
423185fbe5 | ||
|
|
d8d8445c3b | ||
|
|
b12901f0b8 | ||
|
|
3a17f3a5bb | ||
|
|
e951df82c6 | ||
|
|
35450fed80 | ||
|
|
51c7ca4581 | ||
|
|
c0f6c0f318 | ||
|
|
610187ad44 | ||
|
|
49a0132967 | ||
|
|
bb6ade2684 | ||
|
|
45a06c52cb | ||
|
|
29a656d505 | ||
|
|
ad87443232 | ||
|
|
6339d6c305 | ||
|
|
b9f8138ce4 | ||
|
|
c86619a391 | ||
|
|
1d335d80de | ||
|
|
1831f4803c | ||
|
|
c2a77313bf | ||
|
|
994fd3c18b | ||
|
|
955b271eb3 | ||
|
|
9214513cff | ||
|
|
2a19d7a4a7 | ||
|
|
e2b3637d9a | ||
|
|
4a3f6b114c | ||
|
|
18c27229e6 | ||
|
|
dac9a6b805 | ||
|
|
d0fb1bfd8d | ||
|
|
10b69be9c8 | ||
|
|
c276ffa0db | ||
|
|
46905fa513 | ||
|
|
44575685e9 | ||
|
|
28365d1a99 | ||
|
|
4ff61f9a39 | ||
|
|
d0b242e2ea | ||
|
|
9f7a64cbbe | ||
|
|
e7cc5c9932 | ||
|
|
38c5f63334 | ||
|
|
d103197d43 | ||
|
|
50fde3330d | ||
|
|
a7dc882512 | ||
|
|
7478be1de8 | ||
|
|
e2a42eac9b | ||
|
|
488e85bbaa | ||
|
|
c9a8bc7415 | ||
|
|
5a2505c4e3 | ||
|
|
e493f6d2f1 | ||
|
|
c7ce59312c | ||
|
|
5ba84e7e10 | ||
|
|
4c521ccbde | ||
|
|
53ef22f8e7 | ||
|
|
89581a69b4 | ||
|
|
57d5af6108 | ||
|
|
bf03d7cf19 | ||
|
|
41a6594f8a | ||
|
|
9fe8a0e29b | ||
|
|
44bedb490d | ||
|
|
b3cd42eead | ||
|
|
f007eceba6 | ||
|
|
f4527f4078 | ||
|
|
17ef6c5170 | ||
|
|
6a409d113b | ||
|
|
1d2c5e7cb3 | ||
|
|
fa903fe325 | ||
|
|
2b3349127d | ||
|
|
12a5356fa6 | ||
|
|
273aa3164f | ||
|
|
006fa482c9 | ||
|
|
cff7df7bb0 | ||
|
|
d43159df8e | ||
|
|
dd77bc44b9 | ||
|
|
9a3c23cb93 | ||
|
|
dceafe02da | ||
|
|
4c8e27b68f | ||
|
|
99513042d1 | ||
|
|
0085e0cb39 | ||
|
|
11f4ae8140 | ||
|
|
54d726f006 | ||
|
|
31ba7bfe14 | ||
|
|
d546e5a880 | ||
|
|
6cc34d2a6d | ||
|
|
09477a093e | ||
|
|
4bfb4666cd | ||
|
|
0012b7ed4f | ||
|
|
ed5deec4f4 | ||
|
|
92dffeba1d | ||
|
|
eba9e2c250 | ||
|
|
4b6a1a7172 | ||
|
|
76c7faa927 | ||
|
|
8c48c93e6d | ||
|
|
7c5aefe607 | ||
|
|
6191973f13 | ||
|
|
81fca6fb44 | ||
|
|
7f894c9cef | ||
|
|
c34535b638 | ||
|
|
6ad5157cdc | ||
|
|
4607c29b79 | ||
|
|
f9a0f52982 | ||
|
|
6c0d4755e2 | ||
|
|
7ddb256847 | ||
|
|
6c68fcabd5 | ||
|
|
2c3bb20bdd | ||
|
|
9e1624a25f | ||
|
|
1d018a2357 | ||
|
|
a8dc2f72df | ||
|
|
7fe320cded | ||
|
|
0eb5642742 | ||
|
|
3611481176 | ||
|
|
1f8ddd9121 | ||
|
|
59e27b0cee | ||
|
|
c1a523f84b | ||
|
|
6bb1f91bcc | ||
|
|
7d31cf9a70 | ||
|
|
4636417016 | ||
|
|
c22137d83b | ||
|
|
9ecc91077b | ||
|
|
c262cdf644 | ||
|
|
4c0f341523 | ||
|
|
670f536586 | ||
|
|
9887bd9a8c | ||
|
|
94bb3a14e7 | ||
|
|
21fc18b006 | ||
|
|
ac2e6f3964 | ||
|
|
780fca768e | ||
|
|
efc987d932 | ||
|
|
b67d3556cf | ||
|
|
846e548d2c | ||
|
|
5bb4e23773 | ||
|
|
a674ddd8d9 | ||
|
|
85e8a8c980 | ||
|
|
289ced8fbb | ||
|
|
6c26e35a23 | ||
|
|
4f1a7167cf | ||
|
|
4b196bf5be | ||
|
|
030bc04fa5 | ||
|
|
7c9d01071c | ||
|
|
b87d00bae4 | ||
|
|
9f208b9a9c | ||
|
|
18b54a0c07 | ||
|
|
91f2f223e4 | ||
|
|
f397526a8d | ||
|
|
c26586433e | ||
|
|
33c7ad037b | ||
|
|
8e589a4dd0 | ||
|
|
c14c7939b1 | ||
|
|
ded8d505fb | ||
|
|
3424bd2c6a | ||
|
|
a967777ce1 | ||
|
|
0d413b02fa | ||
|
|
818b21781d | ||
|
|
706d653c31 | ||
|
|
b5f0c2b724 | ||
|
|
821762be29 | ||
|
|
11f4265954 | ||
|
|
05b904919c | ||
|
|
78dc569b70 | ||
|
|
22f3112a37 | ||
|
|
9b28749d54 | ||
|
|
9a79890e9d | ||
|
|
e821a6a6db | ||
|
|
33cb580c06 | ||
|
|
32fc1b1193 | ||
|
|
c1abd8c810 | ||
|
|
84aacc5287 | ||
|
|
ee7620ff22 | ||
|
|
e96ede8614 | ||
|
|
42a8ac0dc9 | ||
|
|
10298bf1ee | ||
|
|
13339b1cfe | ||
|
|
9db497336d | ||
|
|
0f18f58f5d | ||
|
|
c504026fd9 | ||
|
|
467661c738 | ||
|
|
8d8ad8939e | ||
|
|
528aa3e9b8 | ||
|
|
44eb36a952 | ||
|
|
3e0f3fcaa7 | ||
|
|
e786ad4bdc | ||
|
|
6d871f85a0 | ||
|
|
2886cac6bc | ||
|
|
1ad9113e11 | ||
|
|
3f8d4b0b08 | ||
|
|
6aa5e34c63 | ||
|
|
bce0f97c1c | ||
|
|
0e759d05e5 | ||
|
|
d7a234e4af | ||
|
|
e45f461bfb | ||
|
|
d571f4b0dd | ||
|
|
a43aaad852 | ||
|
|
30129f3fe3 | ||
|
|
d4e2be2e42 | ||
|
|
77547b258f | ||
|
|
0e7e9ec818 | ||
|
|
d6b8097626 | ||
|
|
b4d94c7979 | ||
|
|
9339f35c11 | ||
|
|
4e5246cbda | ||
|
|
301a430666 | ||
|
|
86f18cc35f | ||
|
|
d5fa7c2a36 | ||
|
|
c84b67d67e | ||
|
|
f3d4a9e496 | ||
|
|
1400845af3 | ||
|
|
1eb31e2b92 | ||
|
|
09fd5e8762 | ||
|
|
24be6bcab3 | ||
|
|
aa2a2d4668 | ||
|
|
175b81d0fd | ||
|
|
97cb95647b | ||
|
|
b375c08422 | ||
|
|
398eb6ef78 | ||
|
|
0754010594 | ||
|
|
5dea4eea14 | ||
|
|
88ef2c9190 | ||
|
|
51850b93ed | ||
|
|
2c6337fa21 | ||
|
|
fcfc9e744d | ||
|
|
5ae442993e | ||
|
|
c595835777 | ||
|
|
eeed665278 | ||
|
|
120cbfff11 | ||
|
|
7b8489fa50 | ||
|
|
2843356057 | ||
|
|
7ed142c1a9 | ||
|
|
69e13203e6 | ||
|
|
0b2d728ae3 | ||
|
|
c82ee269cd | ||
|
|
5b3d26c061 | ||
|
|
9889a2ca29 | ||
|
|
73aeaee494 | ||
|
|
d63c7b8fcd | ||
|
|
20909edad8 | ||
|
|
f1914aad10 | ||
|
|
6fed882155 | ||
|
|
05936783de | ||
|
|
60ae59f801 | ||
|
|
e746693d93 | ||
|
|
65e4d2907f | ||
|
|
e3753dacca | ||
|
|
69883c0944 | ||
|
|
09627451a1 | ||
|
|
3a907781ca | ||
|
|
c60d5d6bfd | ||
|
|
2d75a94b24 | ||
|
|
d2e06c0231 | ||
|
|
1331f22052 | ||
|
|
3dc511f26b | ||
|
|
8de2b13d5f | ||
|
|
eeddcf214e | ||
|
|
5a2bb4aacd | ||
|
|
2af4dc7327 | ||
|
|
9b8bc1c240 | ||
|
|
aeee9731cd | ||
|
|
7a6f3b20d7 | ||
|
|
930c3908e1 | ||
|
|
4974568f5a | ||
|
|
9581139b91 | ||
|
|
d7525a0bae | ||
|
|
e11c25444c | ||
|
|
ef3f7ff68b | ||
|
|
9969299821 | ||
|
|
464783d2ff | ||
|
|
f3aaacae0a | ||
|
|
8e44870cbf | ||
|
|
b3e86e8e63 | ||
|
|
55400e0b9e | ||
|
|
9bbcfbe1dc | ||
|
|
d248870393 | ||
|
|
41fc7ba11e | ||
|
|
5c5a34aab7 | ||
|
|
e44a4d854e | ||
|
|
bc2ac8bed1 | ||
|
|
b87b12f548 | ||
|
|
895a17a46b | ||
|
|
5231be8236 | ||
|
|
a441c28bf5 | ||
|
|
90d441d02f | ||
|
|
63b9692adb | ||
|
|
35eddc42a6 | ||
|
|
468ffffe88 | ||
|
|
51db0eee9f | ||
|
|
0aa369db48 | ||
|
|
dae0d38364 | ||
|
|
b524dcc890 | ||
|
|
fbc3c7ec8c | ||
|
|
48a1b0d210 | ||
|
|
5534fe5fb6 | ||
|
|
051539f936 | ||
|
|
f35d9d69ed | ||
|
|
882d8eee59 | ||
|
|
18f9feb2de | ||
|
|
ddd9258a20 | ||
|
|
1d894b763e | ||
|
|
489c6b36d2 | ||
|
|
a4b956c963 | ||
|
|
9861e3edc5 | ||
|
|
e55d4dfd4f | ||
|
|
472508634a | ||
|
|
b38a5a7520 | ||
|
|
6cd3be8dba | ||
|
|
b14c41722f | ||
|
|
9dbb64073a | ||
|
|
e99af06e67 | ||
|
|
a1201f8fc9 | ||
|
|
922b3ab1d2 | ||
|
|
24505a930d | ||
|
|
a7b790f37c | ||
|
|
7bc76205eb | ||
|
|
948cabcf52 | ||
|
|
9f4786de45 | ||
|
|
6668ce23c7 | ||
|
|
14de70f911 | ||
|
|
d1c0a06730 | ||
|
|
ee5f58f6f9 | ||
|
|
143d3dc858 | ||
|
|
e092178d32 | ||
|
|
cceb2db107 | ||
|
|
59d71369a9 | ||
|
|
2d3ccf1878 | ||
|
|
6f27c9b395 | ||
|
|
bc20c5a1a7 | ||
|
|
67a8509ec4 | ||
|
|
a57e665cc7 | ||
|
|
fe68ba1dac | ||
|
|
952c912dbf | ||
|
|
032d106d89 | ||
|
|
bd23a4d42a | ||
|
|
37440aa104 | ||
|
|
b18672e92d | ||
|
|
c8a1d09ba4 | ||
|
|
99cac55563 | ||
|
|
b29bdba37f | ||
|
|
89c4769b69 | ||
|
|
ab54bbba0e | ||
|
|
2fab08a747 | ||
|
|
f7281ee9a9 | ||
|
|
eaff3970a0 | ||
|
|
bc299677ad | ||
|
|
17dfe9e9df | ||
|
|
2bc8c04bc6 | ||
|
|
961245c883 | ||
|
|
dda8b5c209 | ||
|
|
c8678143c1 | ||
|
|
68b6324365 | ||
|
|
5190e42002 | ||
|
|
1d048d11f3 | ||
|
|
18e6a0f6be | ||
|
|
fa0a934737 | ||
|
|
d528a9ec08 | ||
|
|
41a96433d9 | ||
|
|
1a21344d89 | ||
|
|
06c0dece69 | ||
|
|
03a0294e9c | ||
|
|
30f59387e4 | ||
|
|
078bdedfa9 | ||
|
|
83cf5d536b | ||
|
|
688710fb1c | ||
|
|
1dd3d024ac | ||
|
|
6b84c1658e | ||
|
|
c7bc1abe3c | ||
|
|
df4b2ad904 | ||
|
|
e15e3ea14b | ||
|
|
468b238555 | ||
|
|
8060bc5c85 | ||
|
|
a8fac9e339 | ||
|
|
e4e114e9d4 | ||
|
|
c09b5f0d8a | ||
|
|
74b84bd21f | ||
|
|
8c1bbd795a | ||
|
|
2776f7ee0a | ||
|
|
60b9a5f215 | ||
|
|
4dd08d5255 | ||
|
|
5f5acb4063 | ||
|
|
61a271b297 | ||
|
|
6d6fc074ad | ||
|
|
a6b1a43a86 | ||
|
|
b572c36868 | ||
|
|
975c150a57 | ||
|
|
85781aa3dc | ||
|
|
74b033f785 | ||
|
|
5b1584fbe0 | ||
|
|
1738d535cb | ||
|
|
50ef7f89f9 | ||
|
|
6e9d746b40 | ||
|
|
7106636263 | ||
|
|
5ee7e6326c | ||
|
|
807f16107a | ||
|
|
0cb262dace | ||
|
|
88c7ce9f49 | ||
|
|
d192847ae9 | ||
|
|
c4061d4c2d | ||
|
|
f2fcb46f48 | ||
|
|
7c7542ba91 | ||
|
|
74cd4f6727 | ||
|
|
956600b68f | ||
|
|
a31aede139 | ||
|
|
9c9b450dc7 | ||
|
|
3b0af01f75 | ||
|
|
9a2ef79491 | ||
|
|
98d26c4c45 | ||
|
|
a888d04200 | ||
|
|
3148422d6f | ||
|
|
44b67ac9d4 | ||
|
|
86d99338ed | ||
|
|
b270f5e452 | ||
|
|
4f4414d4f3 | ||
|
|
50b1b8b31f | ||
|
|
0304a3aa29 | ||
|
|
35979a2e91 | ||
|
|
f8af185573 | ||
|
|
e2d447a56b | ||
|
|
0a8211dd5b | ||
|
|
e8ac03ce9c | ||
|
|
88195e2216 | ||
|
|
49a307744d | ||
|
|
fee78529dd | ||
|
|
756b904cb2 | ||
|
|
1441394923 | ||
|
|
65f3ac6330 | ||
|
|
e392777487 | ||
|
|
b0e8104334 | ||
|
|
4dfe19a9fb | ||
|
|
7076f09626 | ||
|
|
0a53f6b2b3 | ||
|
|
2ac8dcbdda | ||
|
|
c23948b5fa | ||
|
|
0fe256fc4e | ||
|
|
671d3a676c | ||
|
|
aad0c47ccf | ||
|
|
c1c4af82e6 | ||
|
|
42a60e8d04 | ||
|
|
4fe9db5189 | ||
|
|
71666ba57c | ||
|
|
08c3e7b43c | ||
|
|
3816a38538 | ||
|
|
4fcc832f9d | ||
|
|
bb3324e2c3 | ||
|
|
2ab506d2e4 | ||
|
|
eb731182fd | ||
|
|
ac6882ef5e | ||
|
|
a7b7a2aa3b | ||
|
|
afac53027c | ||
|
|
0ae9289386 | ||
|
|
3e592bcbf2 | ||
|
|
10b4f5cdc6 | ||
|
|
8f1694ee0d | ||
|
|
f55c28b4be | ||
|
|
de5c5f0c7f | ||
|
|
90d742771e | ||
|
|
afb842bdc2 | ||
|
|
bc85b2eb16 | ||
|
|
4906344045 | ||
|
|
6f300bd14f | ||
|
|
17c696597c | ||
|
|
de4b215bd4 | ||
|
|
aa99029c2a | ||
|
|
73c3eea254 | ||
|
|
4799c3c7c3 | ||
|
|
f7cdf1dd00 | ||
|
|
672d78ff0f | ||
|
|
4b562dc015 | ||
|
|
0567c6b063 | ||
|
|
67aada2e62 | ||
|
|
53569d3edc | ||
|
|
490028e6b2 | ||
|
|
75e8ee1422 | ||
|
|
372b4e707a | ||
|
|
eba64edbf3 | ||
|
|
51fe6e674f | ||
|
|
631c0d75ac | ||
|
|
a456e97681 | ||
|
|
a73a14f14f | ||
|
|
7e3037bd0c | ||
|
|
89c29c3b0c | ||
|
|
905f06a045 | ||
|
|
17895d4795 | ||
|
|
48d0738488 | ||
|
|
2fb6adb36f | ||
|
|
0fde5836c3 | ||
|
|
c40aa09330 | ||
|
|
cae95cddb0 | ||
|
|
e1457fd94c | ||
|
|
7e7082aa7e | ||
|
|
983b9f0832 | ||
|
|
408a51c2aa | ||
|
|
19b95ef72e | ||
|
|
4d84ea8764 | ||
|
|
481de6b1b6 | ||
|
|
a9abdb257d | ||
|
|
e776111d28 | ||
|
|
92c12c9a37 | ||
|
|
a2ff32ce31 | ||
|
|
cf236cb103 | ||
|
|
0505f67048 | ||
|
|
dfbfcb576e | ||
|
|
7c5072e086 | ||
|
|
63a6250bfb | ||
|
|
658c49c841 | ||
|
|
c818001bfb | ||
|
|
586b87916b | ||
|
|
d01dc10ade | ||
|
|
ddcf68f6d1 | ||
|
|
46076df528 | ||
|
|
31fa9cbb66 | ||
|
|
a25daae4a1 | ||
|
|
f26debfa1d | ||
|
|
919bd7fa63 | ||
|
|
f55afd8717 | ||
|
|
ac03c5edbf | ||
|
|
eeba4bef5a | ||
|
|
843a6a272c | ||
|
|
378084354d | ||
|
|
65359b76d5 | ||
|
|
22b7cc5f55 | ||
|
|
3df772df44 | ||
|
|
e7d06692fd | ||
|
|
35d4e813c4 | ||
|
|
852baa28da | ||
|
|
41937dde83 | ||
|
|
593716ee26 | ||
|
|
315bad7e0d | ||
|
|
4dc034cde9 | ||
|
|
d886b5191d | ||
|
|
223b9b3acc | ||
|
|
7871f8e82f | ||
|
|
c265e62062 | ||
|
|
3906afd51c | ||
|
|
1d73a484d9 | ||
|
|
702fa49cb5 | ||
|
|
378de2c3b3 | ||
|
|
56668169c6 | ||
|
|
eb5ccea857 | ||
|
|
05e727d091 | ||
|
|
54e03ac047 | ||
|
|
c96ecc37ac | ||
|
|
b829467ab1 | ||
|
|
4b7ac405c3 | ||
|
|
91219ebc03 | ||
|
|
cfad5bc3db | ||
|
|
d7304d4591 | ||
|
|
92827d1d01 | ||
|
|
03b951346b | ||
|
|
c3033b1e86 | ||
|
|
491f9c6c57 | ||
|
|
d2dd0812f5 | ||
|
|
ff6fa11432 | ||
|
|
1209a8d61d | ||
|
|
d17a8a122a | ||
|
|
bd2a84ce19 | ||
|
|
ee7b9cce08 | ||
|
|
c20d538cf8 | ||
|
|
f07db12d48 | ||
|
|
b083aa7fcb | ||
|
|
309549bc13 | ||
|
|
6dfa583ea0 | ||
|
|
0c66adb782 | ||
|
|
14584d9171 | ||
|
|
3f666ddb6b | ||
|
|
178a8ab4c4 | ||
|
|
19290bebbe | ||
|
|
83ae819b1a | ||
|
|
c80f85e43a | ||
|
|
1d1759265a | ||
|
|
e2f9e7ed38 | ||
|
|
93d16237ba | ||
|
|
fb42bb293e | ||
|
|
5d9ad35791 | ||
|
|
482e48304c | ||
|
|
2ceabfc367 | ||
|
|
1f2cc5172e | ||
|
|
8e7b4b56e1 | ||
|
|
92aba744ff | ||
|
|
688bd6e363 | ||
|
|
8abcd3502b | ||
|
|
0c312ecabc | ||
|
|
b53eca2d3e | ||
|
|
b1b4d34eca | ||
|
|
a1851188ad | ||
|
|
76996eca28 | ||
|
|
a4d222a84e | ||
|
|
9aae931af4 | ||
|
|
ed7e2b2c69 | ||
|
|
341afec0b7 | ||
|
|
17aecd365f | ||
|
|
91ac528f24 | ||
|
|
ceb6411038 | ||
|
|
ba1c3efcdb | ||
|
|
fabdf33a3a | ||
|
|
274b9c7cba | ||
|
|
0540488e2f | ||
|
|
360e274e60 | ||
|
|
7c2a8db309 | ||
|
|
235b2264ef | ||
|
|
53623954e7 | ||
|
|
a2081c1384 | ||
|
|
0cca12f938 | ||
|
|
116e440e8f | ||
|
|
2857b4fc22 | ||
|
|
8ff6bdd064 | ||
|
|
2552194dc1 | ||
|
|
34f4368bc7 | ||
|
|
30f92b5384 | ||
|
|
339829d73f | ||
|
|
de004ee832 | ||
|
|
d628da248d | ||
|
|
d308e894c6 | ||
|
|
6d3edda4bf | ||
|
|
b95515675b | ||
|
|
89ffc21a4c | ||
|
|
c7b25b9f01 | ||
|
|
2f5ecdf139 | ||
|
|
c87a3c309a | ||
|
|
2a36bb6896 | ||
|
|
2a03e35f24 | ||
|
|
49c2113a0a | ||
|
|
5e15691604 | ||
|
|
611fe395ff | ||
|
|
7697e188ce | ||
|
|
0ce55a7257 | ||
|
|
c6ae872232 | ||
|
|
6af6f4dcd5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
jx-callback
|
jx-callback
|
||||||
*.tmp
|
*.tmp
|
||||||
swagger/
|
|
||||||
debug
|
debug
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
467
business/jxstore/cms/api_print.go
Normal file
467
business/jxstore/cms/api_print.go
Normal file
@@ -0,0 +1,467 @@
|
|||||||
|
package cms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"net"
|
||||||
|
"regexp"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
sounda = "sounda" //提示音a
|
||||||
|
soundb = "soundb" //提示音b
|
||||||
|
soundc = "soundc" //提示音c
|
||||||
|
soundd = "soundd" //提示音d
|
||||||
|
sounde = "sounde" //报警音e
|
||||||
|
soundf = "soundf" //报警音f
|
||||||
|
soundg = "soundg" //报警音g
|
||||||
|
)
|
||||||
|
|
||||||
|
type PrintInfo struct {
|
||||||
|
PrintNo string
|
||||||
|
AppID int
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
regexpMobile = regexp.MustCompile("^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\\d{8}$")
|
||||||
|
soundMap = map[string]string{
|
||||||
|
"sounda": "sounda",
|
||||||
|
"soundb": "soundb",
|
||||||
|
"soundc": "soundc",
|
||||||
|
"soundd": "soundd",
|
||||||
|
"sounde": "sounde",
|
||||||
|
"soundf": "soundf",
|
||||||
|
"soundg": "soundg",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func AddPrinter(appID int, printers []*model.AddPrinterParam) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
errs []error
|
||||||
|
)
|
||||||
|
if len(printers) > 50 {
|
||||||
|
return fmt.Errorf("一次最多只能绑定50台!")
|
||||||
|
}
|
||||||
|
for _, v := range printers {
|
||||||
|
if printers2, _ := dao.GetPrinters(db, appID, v.PrintNo, 0, 0); len(printers2) > 0 {
|
||||||
|
// 代表打印机已经在小程序注册了,查询打印机授权门店
|
||||||
|
bindStoreList, err := dao.QueryPrintBindStore(v.PrintNo)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("QueryPrintBindStore err : %v ", err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(bindStoreList) >= 5 {
|
||||||
|
errs = append(errs, fmt.Errorf("当前打印机绑定门店数据超过五个,无法继续绑定"))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
have := false
|
||||||
|
userId := ""
|
||||||
|
for _, bsl := range bindStoreList {
|
||||||
|
if bsl.StoreID == v.StoreId {
|
||||||
|
have = true
|
||||||
|
userId = bsl.UserId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !have {
|
||||||
|
if err := dao.BindStoreList(printers[0], userId); err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("BindStoreList err : %v ", err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
//验证
|
||||||
|
if err = checkPrinterInfo(v.PrintNo, v.Name, "", "", 0); err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// 检查心跳
|
||||||
|
exits, err := dao.CheckHeard(v.PrintNo)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("CheckHeard err : %v ", err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !exits {
|
||||||
|
errs = append(errs, fmt.Errorf("打印机未激活,请激活后在绑定"))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
printer := &model.Printer{
|
||||||
|
AppID: appID,
|
||||||
|
PrintNo: v.PrintNo,
|
||||||
|
Name: v.Name,
|
||||||
|
IccID: "",
|
||||||
|
Status: model.PrinterStatusOffline,
|
||||||
|
Sound: "sounda",
|
||||||
|
PrintKey: v.SIM,
|
||||||
|
IsOnline: 0,
|
||||||
|
Volume: 1,
|
||||||
|
FlowFlag: 0,
|
||||||
|
OfflineCount: 0,
|
||||||
|
UserId: "system_user",
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建打印机
|
||||||
|
if err := InitPrint(printer, v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(errs) > 0 {
|
||||||
|
err = jxutils.BuildErr(errs)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitPrint(printer *model.Printer, printParam *model.AddPrinterParam) error {
|
||||||
|
txDb, _ := dao.Begin(dao.GetDB())
|
||||||
|
// 创建打印机
|
||||||
|
dao.WrapAddIDCULDEntity(printer, "")
|
||||||
|
if err := dao.CreateEntityTx(txDb, printer); err != nil {
|
||||||
|
txDb.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 赋予打印机默认配置
|
||||||
|
day := time.Now()
|
||||||
|
param, err := MarshalJson2String(&model.PrintSetting{
|
||||||
|
CreatedAt: day,
|
||||||
|
UpdatedAt: day,
|
||||||
|
DeletedAt: utils.DefaultTimeValue,
|
||||||
|
PrintNo: printer.PrintNo,
|
||||||
|
CallNameSetting: 64, // 老板
|
||||||
|
BusinessOffLineVoice: 1, // 离线开关
|
||||||
|
BalanceNotEnoughVoice: 1, // 余额不足
|
||||||
|
EveryDayGreetVoice: 1, // 问好
|
||||||
|
BusinessPrintNum: 1, // 商户侧打印次数
|
||||||
|
CustomerPrintNum: 1, // 用户侧打印次数
|
||||||
|
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := dao.CreateEntityTx(txDb, param); err != nil {
|
||||||
|
txDb.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化打印机账户
|
||||||
|
if err := dao.CreateEntityTx(txDb, &model.PrintBill{
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
|
PrintNo: param.PrintNo,
|
||||||
|
PrintBalance: 20000,
|
||||||
|
UserId: "system",
|
||||||
|
}); err != nil {
|
||||||
|
txDb.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化绑定信息
|
||||||
|
if err := dao.BindStoreList(printParam, ""); err != nil {
|
||||||
|
txDb.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer txDb.Commit()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJson2String 工具类
|
||||||
|
func MarshalJson2String(param *model.PrintSetting) (*model.PrintSetting, error) {
|
||||||
|
// 语音设置
|
||||||
|
voiceSetting := &model.VoiceSettingDetail{
|
||||||
|
WaitOrderVoice: model.SettingOpen,
|
||||||
|
RiderTakeOrderVoice: model.SettingOpen,
|
||||||
|
ApplyUserOrderCancelVoice: model.SettingOpen,
|
||||||
|
ApplyRefundOrderVoice: model.SettingOpen,
|
||||||
|
ApplyRefundGoodsVoice: model.SettingOpen,
|
||||||
|
RefundGoodsVoice: model.SettingOpen,
|
||||||
|
ConfirmGoodsVoice: model.SettingOpen,
|
||||||
|
SuccessGoodsVoice: model.SettingOpen,
|
||||||
|
ConsultingPrint: model.SettingOpen,
|
||||||
|
ReminderVoice: model.SettingOpen,
|
||||||
|
CustomerRejectionVoice: model.SettingOpen,
|
||||||
|
CusterRefundVoice: model.SettingOpen,
|
||||||
|
LoseAuthorization: model.SettingOpen,
|
||||||
|
}
|
||||||
|
customerVoiceSettingByte, err := json.Marshal(voiceSetting)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
param.VoiceSetting = string(customerVoiceSettingByte)
|
||||||
|
|
||||||
|
// 打印设置
|
||||||
|
printSetting := &model.PrintSettingDetail{
|
||||||
|
UserOrderCancel: model.SettingOpen,
|
||||||
|
RefundOrder: model.SettingOpen,
|
||||||
|
BusinessOrderCancel: model.SettingOpen,
|
||||||
|
RiderTakeOrder: model.SettingOpen,
|
||||||
|
CusterRefundPrint: model.SettingOpen,
|
||||||
|
WaitOrderPrint: model.SettingOpen,
|
||||||
|
ApplyUserCancelOrder: model.SettingOpen,
|
||||||
|
ApplyUserRefund: model.SettingOpen,
|
||||||
|
OrderCancelSuccess: model.SettingOpen,
|
||||||
|
}
|
||||||
|
pickingSettingByte, err := json.Marshal(printSetting)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
param.PrintSetting = string(pickingSettingByte)
|
||||||
|
return param, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkPrinterInfo(printNo, name, sound, sim string, volume int) (err error) {
|
||||||
|
if printNo != "" {
|
||||||
|
|
||||||
|
}
|
||||||
|
if sim != "" {
|
||||||
|
//if regexpMobile.FindString(sim) == "" {
|
||||||
|
return fmt.Errorf("暂不支持修改sim卡号码!print_no : %v ", printNo)
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
if volume != 0 {
|
||||||
|
if volume <= 0 || volume > 5 {
|
||||||
|
return fmt.Errorf("请输入正确的音量1-5!print_no : %v ", printNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if sound != "" {
|
||||||
|
if soundMap[sound] == "" {
|
||||||
|
return fmt.Errorf("请输入正确的提示音!print_no : %v ", printNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if name != "" {
|
||||||
|
if len(name) > 255 {
|
||||||
|
return fmt.Errorf("打印机备注不能超过255个字符!print_no : %v ", printNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func DelPrinter(appID int, printNos []string, storeId string) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
errs []error
|
||||||
|
)
|
||||||
|
for _, v := range printNos {
|
||||||
|
if printers, _ := dao.GetPrinters(db, appID, v, 0, 0); len(printers) == 0 {
|
||||||
|
errs = append(errs, fmt.Errorf("该应用下未找到该打印机!print_no : %v ", v))
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
if err := dao.DeleteStoreList(printers[0].PrintNo, storeId); err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(errs) > 0 {
|
||||||
|
err = jxutils.BuildErr(errs)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func QueryPrintList(printNo, printKey string, status, isOnline int64, page, size int64) ([]*model.Printer, int, error) {
|
||||||
|
prints, count, err := dao.QueryPrintList(dao.GetDB(), printNo, printKey, status, isOnline, page, size)
|
||||||
|
return prints, count, err
|
||||||
|
}
|
||||||
|
func UpdatePrinter(appID int, printNo string, name, sim, sound *string, volume *int) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
fields []string
|
||||||
|
)
|
||||||
|
//看有没有
|
||||||
|
if printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0); len(printers) == 0 {
|
||||||
|
return fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
||||||
|
} else {
|
||||||
|
if name != nil {
|
||||||
|
if *name != "" {
|
||||||
|
if len(*name) > 20 {
|
||||||
|
return fmt.Errorf("打印机备注不能超过20个字符!print_no : %v ", printNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if printers[0].Name != *name {
|
||||||
|
printers[0].Name = *name
|
||||||
|
fields = append(fields, "name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if sim != nil {
|
||||||
|
if *sim != "" {
|
||||||
|
//if regexpMobile.FindString(*sim) == "" {
|
||||||
|
return fmt.Errorf("暂不支持修改sim卡号码!print_no : %v ", printNo)
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
//if printers[0].SIM != *sim {
|
||||||
|
// printers[0].SIM = *sim
|
||||||
|
// fields = append(fields, "sim")
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
if sound != nil {
|
||||||
|
if *sound != "" {
|
||||||
|
if soundMap[*sound] == "" {
|
||||||
|
return fmt.Errorf("请输入正确的提示音!print_no : %v ", printNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if printers[0].Sound != *sound {
|
||||||
|
printers[0].Sound = *sound
|
||||||
|
fields = append(fields, "sound")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if volume != nil {
|
||||||
|
if *volume <= 0 || *volume > 5 {
|
||||||
|
return fmt.Errorf("请输入正确的音量 1-5!print_no : %v ", printNo)
|
||||||
|
}
|
||||||
|
if printers[0].Volume != *volume {
|
||||||
|
printers[0].Volume = *volume
|
||||||
|
fields = append(fields, "volume")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err = dao.UpdateEntity(db, printers[0], fields...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func DelPrinterSeq(appID int, printNo string) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
//看有没有
|
||||||
|
if printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0); len(printers) == 0 {
|
||||||
|
return fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
||||||
|
} else {
|
||||||
|
printMsgs, _ := dao.GetPrintMsgs2(db, printNo, "", model.PrintMsgAll, model.PrintMsgSuccess)
|
||||||
|
for _, v := range printMsgs {
|
||||||
|
v.DeletedAt = time.Now()
|
||||||
|
if _, err = dao.UpdateEntity(db, v, "DeletedAt"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 简历连接
|
||||||
|
conn, err := net.Dial("tcp", "www.jxcs.net:8000")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
clearPrint := fmt.Sprintf(`{"print_no_clear":%s}`, printNo)
|
||||||
|
// 发送数据
|
||||||
|
if _, err := conn.Write([]byte(clearPrint)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// 等待数据
|
||||||
|
buf := make([]byte, 1024)
|
||||||
|
n, err := conn.Read(buf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if string(buf[:n]) != "ok" {
|
||||||
|
return errors.New("缓存清理失败")
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func DoPrintMsg(appID int, msgID, printNo, content string, orderNo string) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
//打印机必须绑定在该应用下才能打印
|
||||||
|
if printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0); len(printers) == 0 {
|
||||||
|
return fmt.Errorf("未在该应用下获取到此打印机!print_no %v", printNo)
|
||||||
|
}
|
||||||
|
printMsg := &model.PrintMsg{
|
||||||
|
PrintNo: printNo,
|
||||||
|
Content: content,
|
||||||
|
OrderNo: orderNo,
|
||||||
|
MsgID: msgID,
|
||||||
|
Status: event.PrintMsgWait,
|
||||||
|
}
|
||||||
|
|
||||||
|
t, ok := event.PrintObject.GetPrintObj(printNo)
|
||||||
|
if ok {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
t.MsgMap[printNo] <- printMsg
|
||||||
|
printMsg.Status = event.PrintMsgAlreadyLoad
|
||||||
|
} /*else {
|
||||||
|
t = event.NewTcpClient()
|
||||||
|
event.BuildAllMap(t, printNo)
|
||||||
|
event.PrintObject[printNo] = t
|
||||||
|
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
t.MsgMap[printNo] <- printMsg
|
||||||
|
printMsg.Status = event.PrintMsgAlreadyLoad
|
||||||
|
}*/
|
||||||
|
dao.WrapAddIDCULDEntity(printMsg, "")
|
||||||
|
if err = dao.CreateEntity(db, printMsg); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPrintMsgResult struct {
|
||||||
|
MsgID string `json:"msg_id"` //消息ID
|
||||||
|
PrintNo string `json:"print_no"` //打印机编号
|
||||||
|
OrderNo string `json:"order_no"` //订单序号
|
||||||
|
Content string `json:"content"` //订单内容
|
||||||
|
Status int `json:"status"` //打印状态
|
||||||
|
Comment string `json:"comment"` //失败原因
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrintMsg(appID int, msgID string) (printMsg *GetPrintMsgResult, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
if printMsgs, _ := dao.GetPrintMsgs2(db, "", msgID, model.PrintMsgAll, model.PrintMsgAll); len(printMsgs) > 0 {
|
||||||
|
result := printMsgs[0]
|
||||||
|
printMsg = &GetPrintMsgResult{
|
||||||
|
MsgID: result.MsgID,
|
||||||
|
PrintNo: result.PrintNo,
|
||||||
|
OrderNo: result.OrderNo,
|
||||||
|
Content: result.Content,
|
||||||
|
Status: result.Status,
|
||||||
|
Comment: result.Comment,
|
||||||
|
}
|
||||||
|
return printMsg, err
|
||||||
|
} else {
|
||||||
|
return printMsg, fmt.Errorf("未找到该消息!msg_id :%v", msgID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrinterStatus(appID int, printNo string) (status int, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
//看有没有
|
||||||
|
printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0)
|
||||||
|
if len(printers) == 0 {
|
||||||
|
return status, fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
||||||
|
} else {
|
||||||
|
return printers[0].Status + printers[0].IsOnline, nil // 当两个值都唯一时->在线正常
|
||||||
|
//server := "print.jxcs.net:8000"
|
||||||
|
//tcpAddr, err := net.ResolveTCPAddr("tcp4", server)
|
||||||
|
//if err != nil {
|
||||||
|
// //os.Exit(1)
|
||||||
|
// return status, err
|
||||||
|
//}
|
||||||
|
//conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||||
|
//if err != nil {
|
||||||
|
// return status, err
|
||||||
|
//}
|
||||||
|
//status = connHandler(conn, &PrintInfo{
|
||||||
|
// PrintNo: printNo,
|
||||||
|
// AppID: appID,
|
||||||
|
//})
|
||||||
|
//return status, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/tbunionapi"
|
"git.rosy.net.cn/baseapi/platformapi/tbunionapi"
|
||||||
"math"
|
"math"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -63,7 +64,7 @@ func init() {
|
|||||||
JobTimers.s = new(sync.RWMutex)
|
JobTimers.s = new(sync.RWMutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, err error) {
|
func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (jobID int, errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
job = &model.Job{}
|
job = &model.Job{}
|
||||||
@@ -78,21 +79,21 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
// 需根据任务类型做一些参数判断,比如门店商品链接,地址
|
// 需根据任务类型做一些参数判断,比如门店商品链接,地址
|
||||||
if job.JobCategoryID != model.JobCategoryIDUnion {
|
if job.JobCategoryID != model.JobCategoryIDUnion {
|
||||||
if job.AvgPrice == 0 {
|
if job.AvgPrice == 0 {
|
||||||
return errCode, fmt.Errorf("请输入单个任务奖励(保证)金额!")
|
return 0, errCode, fmt.Errorf("请输入单个任务奖励(保证)金额!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch job.JobCategoryID {
|
switch job.JobCategoryID {
|
||||||
case model.JobCategoryIDwmtg:
|
case model.JobCategoryIDwmtg:
|
||||||
if job.Address == "" {
|
if job.Address == "" {
|
||||||
return errCode, fmt.Errorf("外卖推广任务请输入门店地址!")
|
return 0, errCode, fmt.Errorf("外卖推广任务请输入门店地址!")
|
||||||
}
|
}
|
||||||
case model.JobCategoryIDOther:
|
case model.JobCategoryIDOther:
|
||||||
case model.JobCategoryIDDropShipping:
|
case model.JobCategoryIDDropShipping:
|
||||||
if job.DropShippingAt == 0 {
|
if job.DropShippingAt == 0 {
|
||||||
return errCode, fmt.Errorf("一件代发任务请输入承诺x天内发货!")
|
return 0, errCode, fmt.Errorf("一件代发任务请输入承诺x天内发货!")
|
||||||
}
|
}
|
||||||
if job.DropShippingSkuPrice == 0 {
|
if job.DropShippingSkuPrice == 0 {
|
||||||
return errCode, fmt.Errorf("一件代发任务请输入商品价格!")
|
return 0, errCode, fmt.Errorf("一件代发任务请输入商品价格!")
|
||||||
}
|
}
|
||||||
job.CashbackType = model.JobCashbackPrice
|
job.CashbackType = model.JobCashbackPrice
|
||||||
job.LimitCountType = model.JobLimitCountTypeNoLimit
|
job.LimitCountType = model.JobLimitCountTypeNoLimit
|
||||||
@@ -100,27 +101,27 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
job.AuditLimitAt = 0
|
job.AuditLimitAt = 0
|
||||||
case model.JobCategoryIDUnion:
|
case model.JobCategoryIDUnion:
|
||||||
if job.UnionImg == "" || job.UnionQrcodePosition == "" {
|
if job.UnionImg == "" || job.UnionQrcodePosition == "" {
|
||||||
return errCode, fmt.Errorf("联盟任务发布请输入分享的背景图和二维码图方位!")
|
return 0, errCode, fmt.Errorf("联盟任务发布请输入分享的背景图和二维码图方位!")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID)
|
return 0, errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID)
|
||||||
}
|
}
|
||||||
// 需根据返现类型做一些参数判断
|
// 需根据返现类型做一些参数判断
|
||||||
switch job.CashbackType {
|
switch job.CashbackType {
|
||||||
case model.JobCashbackPercentage:
|
case model.JobCashbackPercentage:
|
||||||
if job.Percentage <= 0 || job.Percentage > 100 {
|
if job.Percentage <= 0 || job.Percentage > 100 {
|
||||||
return errCode, fmt.Errorf("返现比例请输入1-100之间的比例!")
|
return 0, errCode, fmt.Errorf("返现比例请输入1-100之间的比例!")
|
||||||
}
|
}
|
||||||
case model.JobCashbackPrice:
|
case model.JobCashbackPrice:
|
||||||
default:
|
default:
|
||||||
return errCode, fmt.Errorf("暂不支持的返现类型! %v", job.CashbackType)
|
return 0, errCode, fmt.Errorf("暂不支持的返现类型! %v", job.CashbackType)
|
||||||
}
|
}
|
||||||
if job.Count <= 0 {
|
if job.Count <= 0 {
|
||||||
return errCode, fmt.Errorf("任务数量不能为0!")
|
return 0, errCode, fmt.Errorf("任务数量不能为0!")
|
||||||
}
|
}
|
||||||
job.SurplusCount = job.Count
|
job.SurplusCount = job.Count
|
||||||
if job.UserID == "" {
|
if job.UserID == "" {
|
||||||
return errCode, fmt.Errorf("任务发起人不能为空!")
|
return 0, errCode, fmt.Errorf("任务发起人不能为空!")
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
userBill *model.UserBill
|
userBill *model.UserBill
|
||||||
@@ -128,45 +129,45 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
|
|
||||||
if ctx.GetToken() != jxcontext.RsmDefultToken {
|
if ctx.GetToken() != jxcontext.RsmDefultToken {
|
||||||
if ctx.GetUserID() != job.UserID {
|
if ctx.GetUserID() != job.UserID {
|
||||||
return errCode, fmt.Errorf("用户信息已过期,请重新登录!")
|
return 0, errCode, fmt.Errorf("用户信息已过期,请重新登录!")
|
||||||
}
|
}
|
||||||
//验证微信绑定
|
//验证微信绑定
|
||||||
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
||||||
return "", err
|
return 0, "", err
|
||||||
}
|
}
|
||||||
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
||||||
userBill, _ = dao.GetUserBill(db, job.UserID, "")
|
userBill, _ = dao.GetUserBill(db, job.UserID, "")
|
||||||
if userBill == nil {
|
if userBill == nil {
|
||||||
return errCode, fmt.Errorf("未查询到该用户的账单!")
|
return 0, errCode, fmt.Errorf("未查询到该用户的账单!")
|
||||||
}
|
}
|
||||||
job.TotalPrice = job.Count * job.AvgPrice
|
job.TotalPrice = job.Count * job.AvgPrice
|
||||||
if userBill.AccountBalance < job.TotalPrice {
|
if userBill.AccountBalance < job.TotalPrice {
|
||||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
return 0, model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
||||||
}
|
}
|
||||||
jobs, _ := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
jobs, _ := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
||||||
if len(jobs) > 0 {
|
if len(jobs) > 0 {
|
||||||
members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal)
|
members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errCode, err
|
return 0, errCode, err
|
||||||
}
|
}
|
||||||
if len(members) <= 0 {
|
if len(members) <= 0 {
|
||||||
return errCode, fmt.Errorf("非会员一天只能发布一起任务,请确认!")
|
return 0, errCode, fmt.Errorf("非会员一天只能发布一起任务,请确认!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if job.Address != "" && (job.Lng == 0 || job.Lat == 0) {
|
if job.Address != "" && (job.Lng == 0 || job.Lat == 0) {
|
||||||
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, job.JobCityCode)
|
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, job.JobCityCode)
|
||||||
if lng == 0 || lat == 0 {
|
if lng == 0 || lat == 0 {
|
||||||
return errCode, fmt.Errorf("请填写完整且正确的门店地址!")
|
return 0, errCode, fmt.Errorf("请填写完整且正确的门店地址!")
|
||||||
}
|
}
|
||||||
job.Lng = jxutils.StandardCoordinate2Int(lng)
|
job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||||
job.Lat = jxutils.StandardCoordinate2Int(lat)
|
job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if job.FinishedAt.Sub(time.Now()) <= 0 {
|
if job.FinishedAt.Sub(time.Now()) <= 0 {
|
||||||
return errCode, fmt.Errorf("任务截止日期必须大于今天!")
|
return 0, errCode, fmt.Errorf("任务截止日期必须大于今天!")
|
||||||
}
|
}
|
||||||
if job2, _ := dao.GetJobWithTitle(db, job.Title); job2 != nil {
|
if job2, _ := dao.GetJobWithTitle(db, job.Title); job2 != nil {
|
||||||
return errCode, fmt.Errorf("任务标题重复,请重新输入!")
|
return 0, errCode, fmt.Errorf("任务标题重复,请重新输入!")
|
||||||
}
|
}
|
||||||
if job.JobCityCode != model.JobCountrywideCode {
|
if job.JobCityCode != model.JobCountrywideCode {
|
||||||
_, _, job.JobCityCode, err = getAddressInfoFromCoord(db, job.JobLng, job.JobLat)
|
_, _, job.JobCityCode, err = getAddressInfoFromCoord(db, job.JobLng, job.JobLat)
|
||||||
@@ -215,7 +216,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
content.WriteString("元")
|
content.WriteString("元")
|
||||||
event.SendSysMessageSimple(content.String(), job.UserID)
|
event.SendSysMessageSimple(content.String(), job.UserID)
|
||||||
}
|
}
|
||||||
return errCode, err
|
return job.ID, errCode, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CancelPublishJob(ctx *jxcontext.Context, jobID int) (err error) {
|
func CancelPublishJob(ctx *jxcontext.Context, jobID int) (err error) {
|
||||||
@@ -904,7 +905,7 @@ func RefreshJobStatus(ctx *jxcontext.Context) (err error) {
|
|||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
globals.SugarLogger.Debugf("RefreshJobStatus begin...")
|
globals.SugarLogger.Debugf("RefreshJobStatus begin...")
|
||||||
jobs, err := dao.GetJobsNoPage(db, nil, nil, []int{model.JobStatusDoing}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, 0, false)
|
jobs, err := dao.GetJobsNoPage(db, nil, nil, nil, []int{model.JobStatusDoing}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, 0, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Debugf("RefreshJobStatus err :%v", err)
|
globals.SugarLogger.Debugf("RefreshJobStatus err :%v", err)
|
||||||
return
|
return
|
||||||
@@ -953,6 +954,35 @@ func RefreshJobStatus(ctx *jxcontext.Context) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dao.Commit(db, txDB)
|
dao.Commit(db, txDB)
|
||||||
|
//美团的先删了
|
||||||
|
if job2.JobCategoryID == model.JobCategoryIDUnion && job2.VendorID == model.VendorIDMTWM {
|
||||||
|
var (
|
||||||
|
configs []*model.NewConfig
|
||||||
|
configUnions []ConfigUnion
|
||||||
|
index1, index2 int
|
||||||
|
)
|
||||||
|
if configs, _ = dao.QueryConfigs(db, "activeBanner", model.ConfigTypeSys, ""); len(configs) > 0 {
|
||||||
|
err = json.Unmarshal([]byte(configs[0].Value), &configUnions)
|
||||||
|
}
|
||||||
|
for k1, config := range configUnions {
|
||||||
|
if config.Type == "美团外卖" {
|
||||||
|
index1 = k1
|
||||||
|
for k2, v := range config.Data {
|
||||||
|
if v.ID == utils.Int2Str(job2.ID) {
|
||||||
|
index2 = k2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var list []*ConfigUnionData
|
||||||
|
list = append(list, configUnions[index1].Data[:index2]...)
|
||||||
|
list = append(list, configUnions[index1].Data[index2+1:]...)
|
||||||
|
configUnions[index1].Data = list
|
||||||
|
data, _ := json.Marshal(configUnions)
|
||||||
|
configs[0].Value = string(data)
|
||||||
|
dao.UpdateEntity(db, configs[0], "Value")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("RefreshJobStatus end...")
|
globals.SugarLogger.Debugf("RefreshJobStatus end...")
|
||||||
@@ -1956,6 +1986,7 @@ func TempJob() (err error) {
|
|||||||
// }, []int{0, 1})
|
// }, []int{0, 1})
|
||||||
//tasksch.HandleTask(task, nil, true).Run()
|
//tasksch.HandleTask(task, nil, true).Run()
|
||||||
//task.GetID()
|
//task.GetID()
|
||||||
|
err = MtUnionJobAutoUpdate(jxcontext.AdminCtx)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1979,6 +2010,7 @@ func GetUnionActList(ctx *jxcontext.Context, vendorID, actType int) (results []*
|
|||||||
result.ActName = v.ActName
|
result.ActName = v.ActName
|
||||||
result.ActSrc = v.ActSrc
|
result.ActSrc = v.ActSrc
|
||||||
result.Ratio = v.Ratio
|
result.Ratio = v.Ratio
|
||||||
|
result.ActRule = v.ActRule
|
||||||
var job *model.Job
|
var job *model.Job
|
||||||
sql := `
|
sql := `
|
||||||
SELECT * FROM job WHERE vendor_id = ? AND union_act_id = ? AND type = ?
|
SELECT * FROM job WHERE vendor_id = ? AND union_act_id = ? AND type = ?
|
||||||
@@ -2049,15 +2081,19 @@ func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resource
|
|||||||
if isImg {
|
if isImg {
|
||||||
bindImg, _ = dao.GetUserUnionBindImg(db, userBind.UnionID, job.UnionActID)
|
bindImg, _ = dao.GetUserUnionBindImg(db, userBind.UnionID, job.UnionActID)
|
||||||
if bindImg != nil {
|
if bindImg != nil {
|
||||||
|
//图片失效了?
|
||||||
if bindImg.UnionImg != "" {
|
if bindImg.UnionImg != "" {
|
||||||
return bindImg.UnionImg, err
|
checkData, _, err := jxutils.DownloadFileByURL(bindImg.UnionImg)
|
||||||
|
if err == nil && checkData != nil {
|
||||||
|
return bindImg.UnionImg, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if link, err = handler.ShareUnionLink(ctx, linkType, utils.Str2Int(job.UnionActID), sid, userID, resourceType, goodsID); err == nil {
|
if link, err = handler.ShareUnionLink(ctx, linkType, utils.Str2Int(job.UnionActID), sid, userID, resourceType, goodsID); err == nil {
|
||||||
if isImg {
|
if isImg {
|
||||||
if resBinary, _, err := jxutils.DownloadFileByURL(link); err == nil {
|
if resBinary, _, err := jxutils.DownloadFileByURL(link); err == nil {
|
||||||
if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+link[strings.LastIndex(link, "/")+1:len(link)]); err == nil {
|
if downloadURL, err := jxutils.UploadExportContent(resBinary, "image/"+utils.Int64ToStr(time.Now().Unix())+link[strings.LastIndex(link, "/")+1:len(link)]); err == nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
link = jxutils.MixWatermarkImg(downloadURL+"?imageView2/1/w/120/h/120/q/75", job.UnionImg, job.UnionQrcodePosition)
|
link = jxutils.MixWatermarkImg(downloadURL+"?imageView2/1/w/120/h/120/q/75", job.UnionImg, job.UnionQrcodePosition)
|
||||||
link += "?imageslim"
|
link += "?imageslim"
|
||||||
@@ -2136,3 +2172,132 @@ func GetVendorMatterRcmmd(ctx *jxcontext.Context, vendorID int, goodsID string,
|
|||||||
handler := partner.GetHandler(vendorID)
|
handler := partner.GetHandler(vendorID)
|
||||||
return handler.GetUnionMatterListRcmmd(ctx, goodsID, rcmmdType, offset, pageSize)
|
return handler.GetUnionMatterListRcmmd(ctx, goodsID, rcmmdType, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ConfigUnion struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Data []*ConfigUnionData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigUnionData struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Content *ConfigUnionDataContent `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigUnionDataContent struct {
|
||||||
|
Imgsrc string `json:"imgSrc"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
List []interface{} `json:"list"`
|
||||||
|
Bgcolor string `json:"bgColor"`
|
||||||
|
Ftcolor string `json:"ftColor"`
|
||||||
|
Topath int `json:"toPath"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
actMap = make(map[int]*partner.ActivityList)
|
||||||
|
jobMap = make(map[int]*dao.GetJobsResult)
|
||||||
|
addList []*partner.ActivityList
|
||||||
|
now = time.Now()
|
||||||
|
)
|
||||||
|
//先找出美团联盟所有发布任务(此任务只用于显示)
|
||||||
|
jobs, err := dao.GetJobsNoPage(db, nil, []int{model.VendorIDMTWM}, []int{model.JobCategoryIDUnion}, []int{model.JobStatusDoing}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, 0, false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//再查美团联盟上的所有活动
|
||||||
|
handler := partner.GetHandler(model.VendorIDMTWM)
|
||||||
|
acts, err := handler.GetUnionActList(ctx, 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, v := range acts {
|
||||||
|
//在有效期内
|
||||||
|
if now.Sub(v.DateBegin) > 0 && v.DateEnd.Sub(now) > 0 {
|
||||||
|
actMap[v.ActID] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//筛一下
|
||||||
|
for _, v := range jobs {
|
||||||
|
jobMap[utils.Str2Int(v.UnionActID)] = v
|
||||||
|
}
|
||||||
|
for k := range actMap {
|
||||||
|
if jobMap[k] == nil {
|
||||||
|
//add
|
||||||
|
addList = append(addList, actMap[k])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//建任务
|
||||||
|
for _, v := range addList {
|
||||||
|
//推广规则
|
||||||
|
storeURL := ""
|
||||||
|
percentage := 0
|
||||||
|
if v.ActRule != "" {
|
||||||
|
if storeURLs := regexp.MustCompile(`href="(.*?)"`).FindStringSubmatch(strings.ReplaceAll(v.ActRule, "\\", "")); len(storeURLs) > 0 {
|
||||||
|
storeURL = storeURLs[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v.Ratio != "" {
|
||||||
|
if ratios := regexp.MustCompile(`([0-9])`).FindStringSubmatch(v.Ratio); len(ratios) > 0 {
|
||||||
|
percentage = utils.Str2Int(ratios[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
job := &model.Job{
|
||||||
|
VendorID: model.VendorIDMTWM,
|
||||||
|
Title: v.ActName,
|
||||||
|
JobCategoryID: model.JobCategoryIDUnion,
|
||||||
|
Content: `
|
||||||
|
<p class='p'>1.本次活动中红包领取时间截止至2022年6月20日24点;</p><p class='p'>2.订单同步为次日,例如12日下的订单,在13日24:00前可同步到返佣订单;</p><p class='p'>3.红包可在美团或美团外卖最新版客户端、美团外卖小程序下单且选择在线支付时使用;</p><p class='p'>4.红包仅限非到店自取外卖订单,下午茶、夜宵、美食、蛋糕、团餐频道、甜点饮品频道使用;</p><p class='p'>5.外卖新人首单红包限新用户(设备、 手机号、美团账号均未在美团外卖下过单)首次下单使用,且不与其他优惠(首减、满减、满赠、套餐增、折扣菜)同享;</p><p class='p'>6.使用红包时下单手机号码必须与收餐人手机号码、领取红包时输入的手机号码一致;</p><p class='p'>7.此活动为部分区域有效,具体红包使用有效期及红包金额以实际收到为准;</p><p class='p'>8.其余问题详见美团外卖客户端:我的一红包一美团红包、商家代金券使用说明;</p><p class='p'>9.活动过程中,任何活动参与方存在虚假交易、恶意套利、作弊等不诚信行为,美团外卖有权取消活动参与方的活动资格,并保留依法追究法律责任的权利;</p><p class='p'>10.活动期间,如出现不可抗力或情势变更的情况,美团外卖可依相关法律法规的规定主张免责;</p><p class='p'>11.分享赚钱中获取到图片后长按图片分享给好友;</p><p class='p'></p>
|
||||||
|
`,
|
||||||
|
Count: 99999,
|
||||||
|
StoreURL: storeURL,
|
||||||
|
SurplusCount: 99999,
|
||||||
|
JobLimitAt: 99999,
|
||||||
|
LimitCountType: model.JobLimitCountTypeNoLimit,
|
||||||
|
Type: model.JobTypeOther,
|
||||||
|
CashbackType: 1,
|
||||||
|
JobCityCode: 999,
|
||||||
|
UnionImg: v.Img,
|
||||||
|
UnionQrcodePosition: "SouthEast",
|
||||||
|
UnionActID: utils.Int2Str(v.ActID),
|
||||||
|
Percentage: percentage,
|
||||||
|
UserID: "1439B3E07D3911EA881A525400E86DC0",
|
||||||
|
FinishedAt: &v.DateEnd,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(job, ctx.GetUserName())
|
||||||
|
dao.CreateEntity(db, job)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//更新banner
|
||||||
|
var (
|
||||||
|
configUnions []*ConfigUnion
|
||||||
|
configs []*model.NewConfig
|
||||||
|
)
|
||||||
|
if configs, _ = dao.QueryConfigs(db, "activeBanner", model.ConfigTypeSys, ""); len(configs) > 0 {
|
||||||
|
err = json.Unmarshal([]byte(configs[0].Value), &configUnions)
|
||||||
|
}
|
||||||
|
for _, config := range configUnions {
|
||||||
|
if config.Type == "美团外卖" {
|
||||||
|
config.Data = append(config.Data, &ConfigUnionData{
|
||||||
|
Title: "banner",
|
||||||
|
ID: utils.Int2Str(job.ID),
|
||||||
|
Content: &ConfigUnionDataContent{
|
||||||
|
Imgsrc: job.UnionImg,
|
||||||
|
Type: 1,
|
||||||
|
List: nil,
|
||||||
|
Bgcolor: "#ffffff",
|
||||||
|
Ftcolor: "#606266",
|
||||||
|
Topath: 10,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data, _ := json.Marshal(configUnions)
|
||||||
|
configs[0].Value = string(data)
|
||||||
|
dao.UpdateEntity(db, configs[0], "Value")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package cms
|
package cms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/recharge_phone_bill"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/q_bida"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -22,7 +27,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price int, lng, lat float64) (orderID, errCode string, err error) {
|
func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price int, lng, lat float64, mobile, flowCode string) (orderID, errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
order *model.Order
|
order *model.Order
|
||||||
@@ -71,6 +76,22 @@ func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price
|
|||||||
DistrictCode: dCode,
|
DistrictCode: dCode,
|
||||||
CityCode: cCode,
|
CityCode: cCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 话费充值
|
||||||
|
if order.OrderType == 7 {
|
||||||
|
// 校验充值编号
|
||||||
|
have, err := CheckMobileAndFlowCode(mobile, flowCode)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
if !have {
|
||||||
|
return "", "", errors.New("充值模板错误")
|
||||||
|
}
|
||||||
|
order.Mobile = mobile
|
||||||
|
order.FlowCode = flowCode
|
||||||
|
order.RechargeStatus = 3 // 当前系统待充值
|
||||||
|
}
|
||||||
|
|
||||||
dao.WrapAddIDCULEntity(order, ctx.GetUserName())
|
dao.WrapAddIDCULEntity(order, ctx.GetUserName())
|
||||||
if err = dao.CreateEntityTx(txDB, order); err != nil {
|
if err = dao.CreateEntityTx(txDB, order); err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
@@ -79,42 +100,245 @@ func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price
|
|||||||
return order.OrderID, errCode, err
|
return order.OrderID, errCode, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType string) (result *financial.WxPayParam, err error) {
|
func CheckMobileAndFlowCode(mobile, flowCode string) (bool, error) {
|
||||||
var (
|
// 校验业务电话和充值号码是否正确
|
||||||
db = dao.GetDB()
|
if mobile == "" || flowCode == "" {
|
||||||
order = &model.Order{
|
return false, errors.New("充值电话费用号码/业务代码不能为空")
|
||||||
OrderID: orderID,
|
}
|
||||||
|
regRuler := "^1[3456789]{1}\\d{9}$"
|
||||||
|
if !regexp.MustCompile(regRuler).MatchString(mobile) {
|
||||||
|
return false, errors.New("电话号码格式校验错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch mobile[0:4] {
|
||||||
|
case "1703", "1705", "1706": // 中国移动
|
||||||
|
if flowCode == recharge_phone_bill.FlowCodeY10Y100 || flowCode == recharge_phone_bill.FlowCodeY10Y200 {
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
|
case "1704", "1707", "1708", "1709": // 中国联通
|
||||||
|
if flowCode == recharge_phone_bill.FlowCodeL10Y50 || flowCode == recharge_phone_bill.FlowCodeL10Y100 || flowCode == recharge_phone_bill.FlowCodeL10Y200 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
case "1700", "1701", "1702 ": // 中国电信
|
||||||
|
if flowCode == recharge_phone_bill.FlowCodeD10Y50 || flowCode == recharge_phone_bill.FlowCodeD10Y100 || flowCode == recharge_phone_bill.FlowCodeD10Y200 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch mobile[0:3] {
|
||||||
|
case "139", "138", "137", "136", "135", "134", "150", "151", "152", "157", "158", "159 182", "183", "184", "187", "188", "147", "198", "178 ", "165": // 中国移动
|
||||||
|
if flowCode == recharge_phone_bill.FlowCodeY10Y100 || flowCode == recharge_phone_bill.FlowCodeY10Y200 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
case "130", "131", "132", "155", "156", "185", "186", "175", "176", "166", "171", "167": // 中国联通
|
||||||
|
if flowCode == recharge_phone_bill.FlowCodeL10Y50 || flowCode == recharge_phone_bill.FlowCodeL10Y100 || flowCode == recharge_phone_bill.FlowCodeL10Y200 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
case "133", "153", "173", "177", "180", "181", "189", "191", "199": // 中国电信
|
||||||
|
if flowCode == recharge_phone_bill.FlowCodeD10Y50 || flowCode == recharge_phone_bill.FlowCodeD10Y100 || flowCode == recharge_phone_bill.FlowCodeD10Y200 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, errors.New("运营商查询错误/充值编码错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, appId string, isChoose int) (result *financial.WxPayParam, err error) {
|
||||||
|
var (
|
||||||
|
tempPayprice int
|
||||||
|
tempPaymethod int
|
||||||
|
db = dao.GetDB()
|
||||||
|
tdb, _ = dao.Begin(db)
|
||||||
|
)
|
||||||
|
orderInfo, err := dao.GetOrderByID(db, orderID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var (
|
||||||
payHandler = &financial.PayHandler{
|
payHandler = &financial.PayHandler{
|
||||||
PayType: payType,
|
PayType: payType,
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
VendorPayType: vendorPayType,
|
VendorPayType: vendorPayType,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
globals.SugarLogger.Debugf("pay begin……")
|
if orderInfo.OrderType == 6 {
|
||||||
err = dao.GetEntity(db, order, "OrderID")
|
return nil, errors.New("不能余额充值余额")
|
||||||
if order.ID == 0 {
|
|
||||||
return result, fmt.Errorf("未找到此订单!")
|
|
||||||
}
|
}
|
||||||
payHandler.Order = order
|
|
||||||
//如果用户没有对应账单信息就给他生成一条
|
// 用户是否使用余额抵消
|
||||||
txDB, _ := dao.Begin(db)
|
if isChoose == 1 { // 余额抵消
|
||||||
defer func() {
|
// 查询用户余额
|
||||||
if r := recover(); r != nil {
|
userBill, err := dao.GetUserBill(db, ctx.GetUserID(), "")
|
||||||
dao.Rollback(db, txDB)
|
if err != nil || userBill == nil { // 出现错误或异常直接使用金钱支付
|
||||||
panic(r)
|
tempPayprice = orderInfo.PayPrice
|
||||||
|
tempPaymethod = model.OrderPayMethodWX
|
||||||
|
} else {
|
||||||
|
if userBill.AccountBalance-orderInfo.PayPrice >= 0 { // 余额大于支付金额,使用余额支付
|
||||||
|
switch orderInfo.OrderType { // 1-发任务,2-会员月卡,3-发快递,4-提现,5-会员年卡,6-使用充值到余额方式的订单,7-话费
|
||||||
|
case model.OrderTypeMember, model.OrderTypeMemberYear:
|
||||||
|
if err := financial.OnWXPayFinished(orderInfo); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case model.OrderTypeDelivery:
|
||||||
|
call := &tonglianpayapi.CallBackResult{}
|
||||||
|
call.TrxID = "ziDingYi_" + utils.Int64ToStr(time.Now().Unix())
|
||||||
|
call.TrxStatus = tonglianpayapi.TrxStatusSuccess
|
||||||
|
if err := financial.OnWxPaySendPage(dao.GetDB(), orderInfo, call, 4); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case model.OrderTypeMobile:
|
||||||
|
if err := financial.OnWxPayTelephone(orderInfo); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return nil, errors.New("其他待处理信息,联系管理员")
|
||||||
|
}
|
||||||
|
//账户支出
|
||||||
|
if err = financial.AddExpendUpdateAccount(tdb, userBill, model.BillTypePayByAccountBalance, orderInfo.PayPrice, 1); err != nil {
|
||||||
|
dao.Rollback(db, tdb)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
} else {
|
||||||
|
// 混合支付
|
||||||
|
tempPayprice = orderInfo.PayPrice - userBill.AccountBalance
|
||||||
|
tempPaymethod = model.OrderPayMethodMix
|
||||||
|
//账户支出
|
||||||
|
if err = financial.AddExpendUpdateAccount(tdb, userBill, model.BillTypePayByAccountBalance, userBill.AccountBalance, 1); err != nil {
|
||||||
|
dao.Rollback(db, tdb)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}()
|
} else { // 原价给
|
||||||
userBill, err := dao.GetUserBill(db, order.UserID, "")
|
tempPayprice = orderInfo.PayPrice
|
||||||
if userBill == nil {
|
tempPaymethod = model.OrderPayMethodWX
|
||||||
err = financial.AddUserBill(txDB, jxutils.GenBillID(), order.UserID)
|
|
||||||
}
|
}
|
||||||
err = payHandler.CreatePay(txDB)
|
|
||||||
dao.Commit(db, txDB)
|
orderInfo.PayPrice = tempPayprice
|
||||||
globals.SugarLogger.Debugf("result : %v", utils.Format4Output(payHandler.WxPayParam, false))
|
orderInfo.PayMethod = tempPaymethod
|
||||||
|
dao.UpdateEntity(dao.GetDB(), orderInfo, "PayPrice", "PayMethod")
|
||||||
|
payHandler.Order = orderInfo
|
||||||
|
//如果用户没有对应账单信息就给他生成一条
|
||||||
|
// 给用户创建一个银行卡账户
|
||||||
|
userBill, err := dao.GetUserBill(db, orderInfo.UserID, "")
|
||||||
|
if userBill == nil {
|
||||||
|
err = financial.AddUserBill(tdb, jxutils.GenBillID(), orderInfo.UserID)
|
||||||
|
}
|
||||||
|
err = payHandler.CreatePay(tdb, appId)
|
||||||
return payHandler.WxPayParam, err
|
return payHandler.WxPayParam, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//余额支付 微信补差值
|
||||||
|
func PayByBalance(ctx *jxcontext.Context, orderID string, isChoose, payType int, vendorPayType, appID string) (*financial.WxPayParam, string, error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
//获取订单信息
|
||||||
|
orderInfo, err := dao.GetOrderByID(db, orderID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "获取订单信息失败", err
|
||||||
|
}
|
||||||
|
//获取用户 会员账户信息
|
||||||
|
userBill, err := dao.GetUserBill(db, orderInfo.UserID, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, "获取用户会员账户余额失败", err
|
||||||
|
}
|
||||||
|
if orderInfo.Status == model.OrderNotPay {
|
||||||
|
//需要充值余额支付的方式//todo 后续添加
|
||||||
|
//if orderInfo.OrderType == 6 {
|
||||||
|
// WxPayParam, err := Pay(ctx, orderInfo.OrderID, payType, vendorPayType, appID, orderInfo.PayPrice)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, "微信支付失败:", err
|
||||||
|
// }
|
||||||
|
// return WxPayParam, "", err
|
||||||
|
//}
|
||||||
|
//快递混合支付
|
||||||
|
if orderInfo.OrderType == model.OrderTypeDelivery {
|
||||||
|
if isChoose == model.PayChooseBalance {
|
||||||
|
// (1)使用余额且 余额大于支付金额
|
||||||
|
if userBill.AccountBalance > orderInfo.PayPrice {
|
||||||
|
globals.SugarLogger.Debug("进入余额支付部分")
|
||||||
|
txDB, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
//增加账单 余额减去相应金额
|
||||||
|
money := userBill.AccountBalance - orderInfo.PayPrice
|
||||||
|
if err = dao.UpdateUserBill(userBill.UserID, money); err != nil {
|
||||||
|
return nil, "余额支付失败", err
|
||||||
|
}
|
||||||
|
//更新订单状态
|
||||||
|
orderInfo.PayMethod = 1
|
||||||
|
orderInfo.Status = 110
|
||||||
|
if _, err := dao.UpdateEntityTx(txDB, orderInfo, "PayMethod"); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
return nil, "更新order.PayMethod状态失败", err
|
||||||
|
}
|
||||||
|
if _, err := dao.UpdateEntityTx(txDB, orderInfo, "Status"); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
return nil, "更新order.Status状态失败", err
|
||||||
|
}
|
||||||
|
//todo 后续需增加其他订单类型
|
||||||
|
//更新快递 订单状态
|
||||||
|
temp_vendor_status := 4
|
||||||
|
if _, err := dao.SetUserVendorOrderStatus(txDB, orderInfo.OrderID, temp_vendor_status); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
return nil, "更新user_vendor_order状态失败", err
|
||||||
|
}
|
||||||
|
dao.Commit(db, txDB)
|
||||||
|
//再次从数据库获取order、userOrder
|
||||||
|
orderNew, err := dao.GetOrderByID(db, orderID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "获取orderNew失败", err
|
||||||
|
}
|
||||||
|
userOrder, err := dao.GetUserVendorOrder(db, orderNew.UserID, orderNew.OrderID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "获取userOrder失败", err
|
||||||
|
}
|
||||||
|
//快递单 同步到qbd
|
||||||
|
if orderNew.Status == 110 && userOrder.OrderStatus == 4 {
|
||||||
|
if err := q_bida.CreateOrder2QBiDa(userOrder, orderInfo.OrderID); err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, "order/user_vendor_order更新状态出错", nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//(2)用户选中余额 但余额<订单总价 需混合微信支付
|
||||||
|
if userBill.AccountBalance == 0 {
|
||||||
|
WxPayParam, err := Pay(ctx, orderInfo.OrderID, payType, vendorPayType, appID, orderInfo.PayPrice)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "微信支付失败:", err
|
||||||
|
}
|
||||||
|
return WxPayParam, "", err
|
||||||
|
} else if userBill.AccountBalance > 0 {
|
||||||
|
//(2)用户使用余额,剩余微信支付
|
||||||
|
totalPrice := orderInfo.PayPrice //订单原价
|
||||||
|
needPay := totalPrice - userBill.AccountBalance //需支付金额
|
||||||
|
WxPayParam, err := Pay(ctx, orderInfo.OrderID, payType, vendorPayType, appID, needPay)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "微信支付失败:", err
|
||||||
|
}
|
||||||
|
return WxPayParam, "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if isChoose == model.PayNotChooseBalance {
|
||||||
|
//(3)不选中余额支付 即直接微信支付
|
||||||
|
WxPayParam, err := Pay(ctx, orderInfo.OrderID, payType, vendorPayType, appID, orderInfo.PayPrice)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "微信支付失败:", err
|
||||||
|
}
|
||||||
|
return WxPayParam, "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
func Cash(ctx *jxcontext.Context, orderID string, payType int, vendorPayType string) (errCode string, err error) {
|
func Cash(ctx *jxcontext.Context, orderID string, payType int, vendorPayType string) (errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
@@ -143,6 +367,15 @@ func GetOrders(ctx *jxcontext.Context, orderID, userID string, orderType int, ci
|
|||||||
return dao.GetOrders(dao.GetDB(), orderID, userID, orderType, cityCodes, utils.Str2Time(fromTime), utils.Str2Time(toTime), keyword, offset, pageSize)
|
return dao.GetOrders(dao.GetDB(), orderID, userID, orderType, cityCodes, utils.Str2Time(fromTime), utils.Str2Time(toTime), keyword, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//id获取订单详情(单条查询)
|
||||||
|
//func GetOrderByID(ctx *jxcontext.Context, orderID int) (errMsg string, err error) {
|
||||||
|
// //var db = dao.GetDB()
|
||||||
|
// if _, err := dao.GetOrderByID(dao.GetDB(), orderID); err != nil {
|
||||||
|
// return "id获取订单详情失败", err
|
||||||
|
// }
|
||||||
|
// return "", err
|
||||||
|
//}
|
||||||
|
|
||||||
func FinishedCashOrders(ctx *jxcontext.Context, orderIDs []string) (err error) {
|
func FinishedCashOrders(ctx *jxcontext.Context, orderIDs []string) (err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
|
|||||||
50
business/jxstore/cms/recharge_server.go
Normal file
50
business/jxstore/cms/recharge_server.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package cms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/recharge_phone_bill"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// QueryUserRecharge 用户查询充值列表
|
||||||
|
func QueryUserRecharge(userId []string, mobile, orderId string, page, pageSize int, startTime, endTime string, rechargeStatus int) ([]*model.RechargeUserModelData, int, error) {
|
||||||
|
if page == 0 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
if pageSize == 0 {
|
||||||
|
pageSize = 10
|
||||||
|
}
|
||||||
|
var start time.Time
|
||||||
|
var end time.Time
|
||||||
|
if startTime != "" {
|
||||||
|
start = utils.Str2Time(startTime)
|
||||||
|
}
|
||||||
|
if endTime != "" {
|
||||||
|
end = utils.Str2Time(endTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return dao.QueryRechargeRecommend(userId, mobile, orderId, page, pageSize, start, end, rechargeStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUserOrderDetail 用户查询订单详情
|
||||||
|
func QueryUserOrderDetail(orderId, mobile string) ([]recharge_phone_bill.QueryOrderDetailResList, error) {
|
||||||
|
data, err := api.TelephoneAPI.QueryOrderDetail("", orderId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
have := false
|
||||||
|
for _, v := range data {
|
||||||
|
if v.Mobile == mobile {
|
||||||
|
have = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if have {
|
||||||
|
return data, err
|
||||||
|
}
|
||||||
|
return nil, errors.New("参数电话号码异常")
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package cms
|
package cms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"net"
|
"net"
|
||||||
@@ -11,28 +12,23 @@ var (
|
|||||||
textChan chan string
|
textChan chan string
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTemp() {
|
func TestTemp2() {
|
||||||
server := "127.0.0.1:8000"
|
server := "127.0.0.1:8000"
|
||||||
tcpAddr, err := net.ResolveTCPAddr("tcp4", server)
|
tcpAddr, err := net.ResolveTCPAddr("tcp4", server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
|
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("tcpaddr", utils.Format4Output(tcpAddr, true))
|
|
||||||
conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Dial err:", err)
|
fmt.Println("Dial err:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
textChan = make(chan string, 10)
|
textChan = make(chan string, 10)
|
||||||
connHandler(conn)
|
connHandler2(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTemp2(data string) {
|
func connHandler2(c net.Conn) {
|
||||||
textChan <- data
|
|
||||||
}
|
|
||||||
|
|
||||||
func connHandler(c net.Conn) {
|
|
||||||
//接收终端输入
|
//接收终端输入
|
||||||
//reader := bufio.NewReader(os.Stdin)
|
//reader := bufio.NewReader(os.Stdin)
|
||||||
//缓冲
|
//缓冲
|
||||||
@@ -64,3 +60,18 @@ func connHandler(c net.Conn) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func connHandler(c net.Conn, printInfo *PrintInfo) (status int) {
|
||||||
|
defer c.Close()
|
||||||
|
//缓冲
|
||||||
|
buf := make([]byte, 1024)
|
||||||
|
data, _ := json.Marshal(printInfo)
|
||||||
|
//写入数据
|
||||||
|
c.Write(data)
|
||||||
|
//服务器端返回的数据写入buf
|
||||||
|
n, _ := c.Read(buf)
|
||||||
|
status = utils.Str2Int(string(buf[:n]))
|
||||||
|
//服务器端回传的信息
|
||||||
|
fmt.Println("server response:", string(buf[:n]))
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|||||||
@@ -414,7 +414,11 @@ func AddUserDeliveryAddress(ctx *jxcontext.Context, address *model.UserDeliveryA
|
|||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
lng := address.Lng
|
lng := address.Lng
|
||||||
lat := address.Lat
|
lat := address.Lat
|
||||||
address.AutoAddress, address.DistrictCode, address.CityCode, err = getAddressInfoFromCoord(db, lng, lat)
|
autoAddress := ""
|
||||||
|
autoAddress, address.DistrictCode, address.CityCode, err = getAddressInfoFromCoord(db, lng, lat)
|
||||||
|
if address.AutoAddress == "" {
|
||||||
|
address.AutoAddress = autoAddress
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
globals.SugarLogger.Debugf("AddUserDeliveryAddress2 address:%s", utils.Format4Output(address, true))
|
globals.SugarLogger.Debugf("AddUserDeliveryAddress2 address:%s", utils.Format4Output(address, true))
|
||||||
txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
@@ -541,6 +545,7 @@ func InvestMember(ctx *jxcontext.Context, memberID int, userID string, isFree bo
|
|||||||
userMembers, err := dao.GetUserMember(db, userIDReal, model.MemberTypeNormal)
|
userMembers, err := dao.GetUserMember(db, userIDReal, model.MemberTypeNormal)
|
||||||
configList, err := dao.QueryConfigs(db, model.ConfigTypeName[model.ConfigTypeMemberCard], model.ConfigTypeMemberCard, "")
|
configList, err := dao.QueryConfigs(db, model.ConfigTypeName[model.ConfigTypeMemberCard], model.ConfigTypeMemberCard, "")
|
||||||
userBill, err := dao.GetUserBill(db, userIDReal, "")
|
userBill, err := dao.GetUserBill(db, userIDReal, "")
|
||||||
|
|
||||||
if len(configList) <= 0 {
|
if len(configList) <= 0 {
|
||||||
return "", fmt.Errorf("未找到会员卡配置!")
|
return "", fmt.Errorf("未找到会员卡配置!")
|
||||||
}
|
}
|
||||||
@@ -554,15 +559,6 @@ func InvestMember(ctx *jxcontext.Context, memberID int, userID string, isFree bo
|
|||||||
memberCard = v
|
memberCard = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isFree {
|
|
||||||
//验证微信绑定
|
|
||||||
if err = auth2.CheckWeixinminiAuthBind(userIDReal); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if userBill.AccountBalance < memberCard.Price {
|
|
||||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足,请充值!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
@@ -570,6 +566,19 @@ func InvestMember(ctx *jxcontext.Context, memberID int, userID string, isFree bo
|
|||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
if !isFree {
|
||||||
|
//验证微信绑定
|
||||||
|
if err = auth2.CheckWeixinminiAuthBind(userIDReal); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if userBill.AccountBalance < memberCard.ActPrice {
|
||||||
|
//if _, err := financial.WXInvestMember(ctx, userMembers[0].MemberTypeID, userMembers[0].UserID); err != nil {
|
||||||
|
// dao.Rollback(db, txDB)
|
||||||
|
//}
|
||||||
|
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足,请充值!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//证明已经开了会员了,相当于续费
|
//证明已经开了会员了,相当于续费
|
||||||
if len(userMembers) > 0 {
|
if len(userMembers) > 0 {
|
||||||
userMember := userMembers[0]
|
userMember := userMembers[0]
|
||||||
@@ -601,7 +610,7 @@ func InvestMember(ctx *jxcontext.Context, memberID int, userID string, isFree bo
|
|||||||
}
|
}
|
||||||
if !isFree {
|
if !isFree {
|
||||||
//支出明细
|
//支出明细
|
||||||
if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypeMember, memberCard.Price, 0); err != nil {
|
if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypeMember, memberCard.ActPrice, 0); err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Store4User struct {
|
type Store4User struct {
|
||||||
@@ -62,165 +53,166 @@ func (x Store4UserList) Swap(i, j int) {
|
|||||||
x[i], x[j] = x[j], x[i]
|
x[i], x[j] = x[j], x[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNearSupplyGoodsStoreByStoreID(ctx *jxcontext.Context, storeID int) (store *model.Store, err error) {
|
//
|
||||||
var (
|
//func GetNearSupplyGoodsStoreByStoreID(ctx *jxcontext.Context, storeID int) (store *model.Store, err error) {
|
||||||
stores []*model.Store
|
// var (
|
||||||
db = dao.GetDB()
|
// stores []*model.Store
|
||||||
)
|
// db = dao.GetDB()
|
||||||
store2, _ := dao.GetStoreDetail(db, storeID, model.VendorIDJX)
|
// )
|
||||||
if store2 == nil {
|
// store2, _ := dao.GetStoreDetail(db, storeID, model.VendorIDJX)
|
||||||
return nil, fmt.Errorf("该门店未绑定京西平台!storeID: %v", storeID)
|
// if store2 == nil {
|
||||||
}
|
// return nil, fmt.Errorf("该门店未绑定京西平台!storeID: %v", storeID)
|
||||||
if store2.IsSupplyGoods == model.YES {
|
// }
|
||||||
return nil, fmt.Errorf("该门店已经是货源门店,无法从其他货源门店进货!storeID: %v", storeID)
|
// if store2.IsSupplyGoods == model.YES {
|
||||||
}
|
// return nil, fmt.Errorf("该门店已经是货源门店,无法从其他货源门店进货!storeID: %v", storeID)
|
||||||
sql := `
|
// }
|
||||||
SELECT a.*
|
// sql := `
|
||||||
FROM store a
|
// SELECT a.*
|
||||||
JOIN store_map b ON b.store_id = a.id
|
// FROM store a
|
||||||
JOIN store c ON c.city_code = a.city_code AND c.id = ?
|
// JOIN store_map b ON b.store_id = a.id
|
||||||
WHERE a.deleted_at = ?
|
// JOIN store c ON c.city_code = a.city_code AND c.id = ?
|
||||||
AND b.deleted_at = ?
|
// WHERE a.deleted_at = ?
|
||||||
AND b.vendor_id = ?
|
// AND b.deleted_at = ?
|
||||||
AND b.is_supply_goods = ?
|
// AND b.vendor_id = ?
|
||||||
AND a.status = ?
|
// AND b.is_supply_goods = ?
|
||||||
`
|
// AND a.status = ?
|
||||||
sqlParams := []interface{}{
|
// `
|
||||||
storeID,
|
// sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue, utils.DefaultTimeValue,
|
// storeID,
|
||||||
model.VendorIDJX, model.YES, model.StoreStatusOpened,
|
// utils.DefaultTimeValue, utils.DefaultTimeValue,
|
||||||
}
|
// model.VendorIDJX, model.YES, model.StoreStatusOpened,
|
||||||
err = dao.GetRows(db, &stores, sql, sqlParams)
|
// }
|
||||||
if len(stores) > 0 {
|
// err = dao.GetRows(db, &stores, sql, sqlParams)
|
||||||
realDistance := float64(0)
|
// if len(stores) > 0 {
|
||||||
for _, v := range stores {
|
// realDistance := float64(0)
|
||||||
distance := jxutils.EarthDistance(jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat), jxutils.IntCoordinate2Standard(store2.Lng), jxutils.IntCoordinate2Standard(store2.Lat))
|
// for _, v := range stores {
|
||||||
if realDistance == 0 {
|
// distance := jxutils.EarthDistance(jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat), jxutils.IntCoordinate2Standard(store2.Lng), jxutils.IntCoordinate2Standard(store2.Lat))
|
||||||
realDistance = distance
|
// if realDistance == 0 {
|
||||||
store = v
|
// realDistance = distance
|
||||||
} else {
|
// store = v
|
||||||
if realDistance > distance {
|
// } else {
|
||||||
realDistance = distance
|
// if realDistance > distance {
|
||||||
store = v
|
// realDistance = distance
|
||||||
}
|
// store = v
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return store, err
|
// }
|
||||||
}
|
// return store, err
|
||||||
|
//}
|
||||||
func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius int, needWalkDistance, isJds bool) (storeList []*Store4User, err error) {
|
//
|
||||||
const (
|
//func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius int, needWalkDistance, isJds bool) (storeList []*Store4User, err error) {
|
||||||
maxStoreCount4User = 5
|
// const (
|
||||||
)
|
// maxStoreCount4User = 5
|
||||||
|
// )
|
||||||
var (
|
//
|
||||||
sql string
|
// var (
|
||||||
sqlParams []interface{}
|
// sql string
|
||||||
)
|
// sqlParams []interface{}
|
||||||
|
// )
|
||||||
lng2, _ := jxutils.ConvertDistanceToLogLat(lng, lat, float64(maxRadius), 90)
|
//
|
||||||
_, lat2 := jxutils.ConvertDistanceToLogLat(lng, lat, float64(maxRadius), 0)
|
// lng2, _ := jxutils.ConvertDistanceToLogLat(lng, lat, float64(maxRadius), 90)
|
||||||
lng1 := lng - (lng2 - lng)
|
// _, lat2 := jxutils.ConvertDistanceToLogLat(lng, lat, float64(maxRadius), 0)
|
||||||
lat1 := lat - (lat2 - lat)
|
// lng1 := lng - (lng2 - lng)
|
||||||
// globals.SugarLogger.Debugf("%f,%f,%f,%f\n", lng1, lng2, lat1, lat2)
|
// lat1 := lat - (lat2 - lat)
|
||||||
if !isJds {
|
// // globals.SugarLogger.Debugf("%f,%f,%f,%f\n", lng1, lng2, lat1, lat2)
|
||||||
sql = `
|
// if !isJds {
|
||||||
SELECT t1.*,
|
// sql = `
|
||||||
city.name city_name
|
// SELECT t1.*,
|
||||||
FROM store t1
|
// city.name city_name
|
||||||
JOIN place city ON city.code = t1.city_code
|
// FROM store t1
|
||||||
JOIN store_map sm ON sm.store_id = t1.id AND sm.vendor_id = ? AND sm.deleted_at = ? AND sm.status <> ?
|
// JOIN place city ON city.code = t1.city_code
|
||||||
WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.lng > ? AND t1.lng < ? AND t1.lat > ? AND t1.lat < ?
|
// JOIN store_map sm ON sm.store_id = t1.id AND sm.vendor_id = ? AND sm.deleted_at = ? AND sm.status <> ?
|
||||||
AND sm.is_order <> ?
|
// WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.lng > ? AND t1.lng < ? AND t1.lat > ? AND t1.lat < ?
|
||||||
AND t1.id <> ?
|
// AND sm.is_order <> ?
|
||||||
ORDER BY t1.id
|
// AND t1.id <> ?
|
||||||
`
|
// ORDER BY t1.id
|
||||||
sqlParams = []interface{}{
|
// `
|
||||||
model.VendorIDJX, utils.DefaultTimeValue, model.StoreStatusDisabled,
|
// sqlParams = []interface{}{
|
||||||
utils.DefaultTimeValue, model.StoreStatusDisabled, jxutils.StandardCoordinate2Int(lng1), jxutils.StandardCoordinate2Int(lng2), jxutils.StandardCoordinate2Int(lat1), jxutils.StandardCoordinate2Int(lat2),
|
// model.VendorIDJX, utils.DefaultTimeValue, model.StoreStatusDisabled,
|
||||||
model.YES,
|
// utils.DefaultTimeValue, model.StoreStatusDisabled, jxutils.StandardCoordinate2Int(lng1), jxutils.StandardCoordinate2Int(lng2), jxutils.StandardCoordinate2Int(lat1), jxutils.StandardCoordinate2Int(lat2),
|
||||||
model.MatterStoreID,
|
// model.YES,
|
||||||
}
|
// model.MatterStoreID,
|
||||||
} else {
|
// }
|
||||||
sql = `
|
// } else {
|
||||||
SELECT t1.*,
|
// sql = `
|
||||||
city.name city_name
|
// SELECT t1.*,
|
||||||
FROM store t1
|
// city.name city_name
|
||||||
JOIN place city ON city.code = t1.city_code
|
// FROM store t1
|
||||||
JOIN store_map sm ON sm.store_id = t1.id AND sm.vendor_id = ? AND sm.deleted_at = ? AND sm.status = ?
|
// JOIN place city ON city.code = t1.city_code
|
||||||
WHERE t1.deleted_at = ? AND t1.status = ? AND t1.lng > ? AND t1.lng < ? AND t1.lat > ? AND t1.lat < ?
|
// JOIN store_map sm ON sm.store_id = t1.id AND sm.vendor_id = ? AND sm.deleted_at = ? AND sm.status = ?
|
||||||
AND sm.is_order <> ?
|
// WHERE t1.deleted_at = ? AND t1.status = ? AND t1.lng > ? AND t1.lng < ? AND t1.lat > ? AND t1.lat < ?
|
||||||
AND t1.id <> ?
|
// AND sm.is_order <> ?
|
||||||
ORDER BY t1.id
|
// AND t1.id <> ?
|
||||||
`
|
// ORDER BY t1.id
|
||||||
sqlParams = []interface{}{
|
// `
|
||||||
model.VendorIDJDShop, utils.DefaultTimeValue, model.StoreStatusOpened,
|
// sqlParams = []interface{}{
|
||||||
utils.DefaultTimeValue, model.StoreStatusOpened, jxutils.StandardCoordinate2Int(lng1), jxutils.StandardCoordinate2Int(lng2), jxutils.StandardCoordinate2Int(lat1), jxutils.StandardCoordinate2Int(lat2),
|
// model.VendorIDJDShop, utils.DefaultTimeValue, model.StoreStatusOpened,
|
||||||
model.YES,
|
// utils.DefaultTimeValue, model.StoreStatusOpened, jxutils.StandardCoordinate2Int(lng1), jxutils.StandardCoordinate2Int(lng2), jxutils.StandardCoordinate2Int(lat1), jxutils.StandardCoordinate2Int(lat2),
|
||||||
model.MatterStoreID,
|
// model.YES,
|
||||||
}
|
// model.MatterStoreID,
|
||||||
}
|
// }
|
||||||
var storeList1 []*Store4User
|
// }
|
||||||
if err = dao.GetRows(dao.GetDB(), &storeList1, sql, sqlParams...); err == nil {
|
// var storeList1 []*Store4User
|
||||||
var storeList2 []*Store4User
|
// if err = dao.GetRows(dao.GetDB(), &storeList1, sql, sqlParams...); err == nil {
|
||||||
for _, v := range storeList1 {
|
// var storeList2 []*Store4User
|
||||||
distance := jxutils.Point2StoreDistance(lng, lat, v.Lng, v.Lat, v.DeliveryRangeType, v.DeliveryRange)
|
// for _, v := range storeList1 {
|
||||||
if distance > 0 || (lng == jxutils.IntCoordinate2Standard(v.Lng) && lat == jxutils.IntCoordinate2Standard(v.Lat)) {
|
// distance := jxutils.Point2StoreDistance(lng, lat, v.Lng, v.Lat, v.DeliveryRangeType, v.DeliveryRange)
|
||||||
v.Distance = distance
|
// if distance > 0 || (lng == jxutils.IntCoordinate2Standard(v.Lng) && lat == jxutils.IntCoordinate2Standard(v.Lat)) {
|
||||||
storeList2 = append(storeList2, v)
|
// v.Distance = distance
|
||||||
}
|
// storeList2 = append(storeList2, v)
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
// 为了审核用
|
//
|
||||||
if len(storeList2) == 0 {
|
// // 为了审核用
|
||||||
sql2 := `
|
// if len(storeList2) == 0 {
|
||||||
SELECT t1.*,
|
// sql2 := `
|
||||||
city.name city_name
|
// SELECT t1.*,
|
||||||
FROM store t1
|
// city.name city_name
|
||||||
JOIN place city ON city.code = t1.city_code
|
// FROM store t1
|
||||||
WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.id = ?
|
// JOIN place city ON city.code = t1.city_code
|
||||||
`
|
// WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.id = ?
|
||||||
sqlParams2 := []interface{}{
|
// `
|
||||||
// model.VendorIDJX, utils.DefaultTimeValue, model.StoreStatusDisabled,
|
// sqlParams2 := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
// // model.VendorIDJX, utils.DefaultTimeValue, model.StoreStatusDisabled,
|
||||||
model.StoreStatusDisabled,
|
// utils.DefaultTimeValue,
|
||||||
// jxutils.StandardCoordinate2Int(0),
|
// model.StoreStatusDisabled,
|
||||||
// jxutils.StandardCoordinate2Int(10000),
|
// // jxutils.StandardCoordinate2Int(0),
|
||||||
// jxutils.StandardCoordinate2Int(0),
|
// // jxutils.StandardCoordinate2Int(10000),
|
||||||
// jxutils.StandardCoordinate2Int(10000),
|
// // jxutils.StandardCoordinate2Int(0),
|
||||||
// model.YES,
|
// // jxutils.StandardCoordinate2Int(10000),
|
||||||
102919, //商城模板店
|
// // model.YES,
|
||||||
}
|
// 102919, //商城模板店
|
||||||
dao.GetRows(dao.GetDB(), &storeList2, sql2, sqlParams2...)
|
// }
|
||||||
// if len(storeList2) > 1 {
|
// dao.GetRows(dao.GetDB(), &storeList2, sql2, sqlParams2...)
|
||||||
// storeList2 = storeList2[:1]
|
// // if len(storeList2) > 1 {
|
||||||
// }
|
// // storeList2 = storeList2[:1]
|
||||||
}
|
// // }
|
||||||
|
// }
|
||||||
// 如果要求以步行距离来算
|
//
|
||||||
if needWalkDistance {
|
// // 如果要求以步行距离来算
|
||||||
var coordList []*autonavi.Coordinate
|
// if needWalkDistance {
|
||||||
for _, v := range storeList2 {
|
// var coordList []*autonavi.Coordinate
|
||||||
coordList = append(coordList, &autonavi.Coordinate{
|
// for _, v := range storeList2 {
|
||||||
Lng: v.FloatLng,
|
// coordList = append(coordList, &autonavi.Coordinate{
|
||||||
Lat: v.FloatLat,
|
// Lng: v.FloatLng,
|
||||||
})
|
// Lat: v.FloatLat,
|
||||||
}
|
// })
|
||||||
if distanceList, err2 := api.AutonaviAPI.BatchWalkingDistance(lng, lat, coordList); err2 == nil {
|
// }
|
||||||
for k, v := range storeList2 {
|
// if distanceList, err2 := api.AutonaviAPI.BatchWalkingDistance(lng, lat, coordList); err2 == nil {
|
||||||
v.WalkDistance = int(distanceList[k])
|
// for k, v := range storeList2 {
|
||||||
}
|
// v.WalkDistance = int(distanceList[k])
|
||||||
} else {
|
// }
|
||||||
return nil, err2
|
// } else {
|
||||||
}
|
// return nil, err2
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
sort.Sort(Store4UserList(storeList2))
|
//
|
||||||
storeList = storeList2
|
// sort.Sort(Store4UserList(storeList2))
|
||||||
if len(storeList) > maxStoreCount4User {
|
// storeList = storeList2
|
||||||
storeList = storeList[:maxStoreCount4User]
|
// if len(storeList) > maxStoreCount4User {
|
||||||
}
|
// storeList = storeList[:maxStoreCount4User]
|
||||||
}
|
// }
|
||||||
return storeList, err
|
// }
|
||||||
}
|
// return storeList, err
|
||||||
|
//}
|
||||||
|
|||||||
97
business/jxstore/event/event_print.go
Normal file
97
business/jxstore/event/event_print.go
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
PrintObject *PrintObjectStruct // 缓存的打印机对象
|
||||||
|
PrintAddrAndIp *PrintAddrAndIpStruct // 缓存打印机地址:[ip:printNo] event 文件包,connect只能获取到addr
|
||||||
|
PrintIpAndAddr *PrintIpAndAddrStruct // 缓存打印机地址:[printNo:ip] api_controller 只能获取到printNo
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
fmt.Println("初始化打印机对象")
|
||||||
|
PrintObject = &PrintObjectStruct{
|
||||||
|
PrintObject: make(map[string]*TcpClient),
|
||||||
|
RWMutex: new(sync.RWMutex),
|
||||||
|
}
|
||||||
|
PrintAddrAndIp = &PrintAddrAndIpStruct{
|
||||||
|
PrintObject: make(map[string]string),
|
||||||
|
RWMutex: new(sync.RWMutex),
|
||||||
|
}
|
||||||
|
PrintIpAndAddr = &PrintIpAndAddrStruct{
|
||||||
|
PrintObject: make(map[string]string),
|
||||||
|
RWMutex: new(sync.RWMutex),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrintObjectStruct struct {
|
||||||
|
PrintObject map[string]*TcpClient
|
||||||
|
*sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PrintObjectStruct) GetPrintObj(printNo string) (*TcpClient, bool) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
tcpObj, ok := PrintObject.PrintObject[printNo]
|
||||||
|
return tcpObj, ok
|
||||||
|
}
|
||||||
|
func (p *PrintObjectStruct) SetPrintObj(printNo string, tcpObj *TcpClient) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
PrintObject.PrintObject[printNo] = tcpObj
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PrintObjectStruct) DelPrintObj(printNo string) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
delete(PrintObject.PrintObject, printNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrintAddrAndIpStruct struct {
|
||||||
|
PrintObject map[string]string
|
||||||
|
*sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PrintAddrAndIpStruct) GetPrintAddrAndIp(ip string) (string, bool) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
printNo, ok := PrintAddrAndIp.PrintObject[ip]
|
||||||
|
return printNo, ok
|
||||||
|
}
|
||||||
|
func (p *PrintAddrAndIpStruct) SetPrintAddrAndIp(ip string, printNo string) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
PrintAddrAndIp.PrintObject[ip] = printNo
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PrintAddrAndIpStruct) DelPrintAddrAndIp(ip string) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
delete(PrintAddrAndIp.PrintObject, ip)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrintIpAndAddrStruct struct {
|
||||||
|
PrintObject map[string]string
|
||||||
|
*sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PrintIpAndAddrStruct) GetPrintIpAndAddr(printNo string) (string, bool) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
tcpObj, ok := PrintIpAndAddr.PrintObject[printNo]
|
||||||
|
return tcpObj, ok
|
||||||
|
}
|
||||||
|
func (p *PrintIpAndAddrStruct) SetPrintIpAndAddr(printNo string, ip string) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
PrintIpAndAddr.PrintObject[printNo] = ip
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PrintIpAndAddrStruct) DelPrintIpAndAddr(printNo string) {
|
||||||
|
p.RLock()
|
||||||
|
defer p.RUnlock()
|
||||||
|
delete(PrintIpAndAddr.PrintObject, printNo)
|
||||||
|
}
|
||||||
373
business/jxstore/event/event_tcp.go
Normal file
373
business/jxstore/event/event_tcp.go
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConnRead 获取链接数据
|
||||||
|
func ConnRead(c net.Conn) ([]byte, int, error) {
|
||||||
|
buffer := make([]byte, 1024*2)
|
||||||
|
n, err := c.Read(buffer)
|
||||||
|
return buffer, n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListenTcp 入口
|
||||||
|
func ListenTcp() {
|
||||||
|
l, err := net.Listen("tcp", ":8000")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("listen error:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
c, err := l.Accept()
|
||||||
|
if err != nil || c == nil {
|
||||||
|
fmt.Println("accept error:", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
fn := func() {
|
||||||
|
// 捕获异常 防止waitGroup阻塞
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
fmt.Println("recover err = ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := handleConn(c); err != nil {
|
||||||
|
c.Close()
|
||||||
|
Poll.Wait()
|
||||||
|
Poll.Stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Poll.AddJob(fn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleConn(c net.Conn) error {
|
||||||
|
if c == nil {
|
||||||
|
return errors.New("conn is nil")
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
buffer, n, err := ConnRead(c)
|
||||||
|
printRemoteAddr := c.RemoteAddr().String()
|
||||||
|
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
||||||
|
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
|
||||||
|
if err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
fmt.Println("connection close")
|
||||||
|
} else {
|
||||||
|
fmt.Println("ReadString err:", err)
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("--------printRemoteAddr := %s,printNo := %s", printRemoteAddr, printNoByIP)
|
||||||
|
if printNo, ok := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr); ok {
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
|
||||||
|
PrintObject.DelPrintObj(printNo)
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
||||||
|
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
|
||||||
|
} else {
|
||||||
|
printStatusOff := make(map[string]int, 0)
|
||||||
|
for ip, pn := range PrintAddrAndIp.PrintObject {
|
||||||
|
if ip == printRemoteAddr {
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(pn)
|
||||||
|
PrintObject.DelPrintObj(printNo)
|
||||||
|
} else if pn != "" {
|
||||||
|
printStatusOff[pn] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
//看是心跳还是打印回调
|
||||||
|
data := hex.EncodeToString(buffer[:n])
|
||||||
|
var (
|
||||||
|
printNo string = "" //打印机编号
|
||||||
|
heartbeat bool = false
|
||||||
|
callback bool = false
|
||||||
|
)
|
||||||
|
if strings.Contains(data, heartText) || strings.Contains(data, heartTextNew) {
|
||||||
|
printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8])
|
||||||
|
printNo = string(printNoData)
|
||||||
|
heartbeat = true
|
||||||
|
} else if strings.Contains(data, printText) || strings.Contains(data, printTextNew) { //打印回调
|
||||||
|
_, printNo = getCallbackMsgInfo(data)
|
||||||
|
callback = true
|
||||||
|
}
|
||||||
|
|
||||||
|
t, ok := PrintObject.GetPrintObj(printNo)
|
||||||
|
if !ok || t.Clients[printNo] == nil || time.Now().Sub(t.Clients[printNo].StatusTime).Seconds() >= 120 {
|
||||||
|
t = NewTcpClient()
|
||||||
|
}
|
||||||
|
|
||||||
|
if heartbeat {
|
||||||
|
// 证明是心跳
|
||||||
|
Heartbeat(c, t, data, printNo, printRemoteAddr)
|
||||||
|
} else if callback {
|
||||||
|
// 打印回调
|
||||||
|
Callback(c, t, data, printNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) printFail() (err error) {
|
||||||
|
//新开机的打印失败和错误的
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
prints, _ := dao.GetPrintMsgs(db, "", []int{printMsgFail, printMsgErr, PrintMsgAlreadyLoad, printMsgAlreadySend}, time.Now().Add(-time.Hour*3), time.Now(), 0, 999)
|
||||||
|
for _, printMsg := range prints {
|
||||||
|
t.addMsgChan(printMsg)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) changePrintMsg(data string, orderNo int64, printNo string) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
comment string
|
||||||
|
status int
|
||||||
|
)
|
||||||
|
//1、先找出打印机编号和订单序列号,这两个确定唯一一条消息?
|
||||||
|
//通过参数传进来
|
||||||
|
//2、打印成功改变打印表的状态
|
||||||
|
if strings.Contains(data, printSuccessText) || strings.Contains(data, printSuccessTextNew) {
|
||||||
|
status = printMsgSuccess
|
||||||
|
comment = "回调成功,修改打印状态"
|
||||||
|
} else {
|
||||||
|
//打印失败也改变状态并更新失败原因
|
||||||
|
status = printMsgFail
|
||||||
|
comment = printErrMap[data[12:14]]
|
||||||
|
}
|
||||||
|
//这里序号重复会有问题
|
||||||
|
if printMsgs, err := dao.GetPrintMsgNoPage(db, printNo, orderNo); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("changePrintMsg err :[%v]", err)
|
||||||
|
return err
|
||||||
|
} else if len(printMsgs) == 0 {
|
||||||
|
globals.SugarLogger.Debugf("changePrintMsg err ,not found printMsg printNo:[%v], orderNo :[%v]", printNo, orderNo)
|
||||||
|
} else if len(printMsgs) > 0 {
|
||||||
|
for _, v := range printMsgs {
|
||||||
|
v.Comment = comment
|
||||||
|
v.Status = status
|
||||||
|
dao.UpdateEntity(db, v, "Comment", "Status")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func HandleTcpMessages(t *TcpClient, printNo string) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
offset, pageSize = 0, 10
|
||||||
|
)
|
||||||
|
if !t.isExistMsg(printNo) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fn := func() {
|
||||||
|
//for {
|
||||||
|
// time.Sleep(2 * time.Second)
|
||||||
|
if t.TimeoutMap[printNo] == true {
|
||||||
|
timeNow := time.Now()
|
||||||
|
timeStart := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
|
||||||
|
timeEnd := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
|
||||||
|
prints, _ := dao.GetPrintMsgs(db, printNo, []int{PrintMsgWait}, timeStart.AddDate(0, 0, -1), timeEnd, offset, pageSize)
|
||||||
|
for _, printMsg := range prints {
|
||||||
|
printMsg.Status = PrintMsgAlreadyLoad
|
||||||
|
//先避免重复读再插到channel?
|
||||||
|
if _, err := dao.UpdateEntity(db, printMsg, "Status"); err == nil {
|
||||||
|
if err = t.addMsgChan(printMsg); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("HandleTcpMessages addMsgChan Err: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Poll.AddJob(fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) readTimeoutMap(key string) bool {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
return t.TimeoutMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
func doPrint(t *TcpClient, key string) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
|
||||||
|
if !t.isExistMsg(key) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fn := func() {
|
||||||
|
for {
|
||||||
|
if t.TimeoutMap[key] == true {
|
||||||
|
select {
|
||||||
|
case printMsg, ok := <-t.MsgMap[key]:
|
||||||
|
if !ok {
|
||||||
|
globals.SugarLogger.Debugf("doPrint err !ok ...")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
data []byte
|
||||||
|
c net.Conn
|
||||||
|
)
|
||||||
|
if printMsg == nil {
|
||||||
|
globals.SugarLogger.Debugf("print msg is nil")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = checkPrintMsg(db, printMsg); err == nil {
|
||||||
|
status := t.getPrintStatus(printMsg.PrintNo)
|
||||||
|
switch status {
|
||||||
|
//只有在线才打印内容
|
||||||
|
case printerStatusOnline:
|
||||||
|
if c = t.getPrintConn(printMsg.PrintNo); c != nil {
|
||||||
|
data, err = buildMsg(printMsg)
|
||||||
|
}
|
||||||
|
case printerStatusOffline:
|
||||||
|
err = fmt.Errorf("打印机离线!")
|
||||||
|
case printerStatusOnlineWithoutPaper:
|
||||||
|
err = fmt.Errorf("打印机缺纸!")
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("打印机状态未知!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c == nil {
|
||||||
|
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(key)
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddrIP)
|
||||||
|
PrintObject.DelPrintObj(key)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
printMsg.Status = printMsgErr
|
||||||
|
printMsg.Comment = err.Error()
|
||||||
|
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
||||||
|
|
||||||
|
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(key)
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddrIP)
|
||||||
|
PrintObject.DelPrintObj(key)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = c.Write(data); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
||||||
|
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(key)
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddrIP)
|
||||||
|
PrintObject.DelPrintObj(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//等待回调
|
||||||
|
dataStr := <-t.CallBackMap[key]
|
||||||
|
if dataStr != "" {
|
||||||
|
a, b := getCallbackMsgInfo(dataStr)
|
||||||
|
t.changePrintMsg(dataStr, a, b)
|
||||||
|
// 查询打印机是否扣费,未扣费就扣费,已经扣费不做处理
|
||||||
|
have, err2 := dao.QueryOrderDeductionRecord(db, b, utils.Int64ToStr(a))
|
||||||
|
if err2 == nil && !have {
|
||||||
|
// 扣除打印机账号金额
|
||||||
|
if err = dao.DeductionPrintBalance(db, b); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("扣除用户打印机金额错误 %s", err)
|
||||||
|
} else {
|
||||||
|
// 添加打印记录(支出记录)
|
||||||
|
if err = dao.AddPrintRecord(db, &model.PrintBillRecord{
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
|
PrintNo: b,
|
||||||
|
PayType: 2,
|
||||||
|
PayMoney: 1, // 固定支出一分钱
|
||||||
|
OrderId: utils.Int64ToStr(a),
|
||||||
|
UserId: "",
|
||||||
|
}); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("添加打印机订单支付记录错误 %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("今天已经扣除过了! %v %d %s", err2, a, b)
|
||||||
|
}
|
||||||
|
// 回调重置打印机状态时间
|
||||||
|
t.Clients[b].StatusTime = time.Now()
|
||||||
|
//判断音频暂停?
|
||||||
|
//收到打印成功回调后,如果消息中有音频,需要等待一下,等上一个音频播完
|
||||||
|
//暂停时间就暂时取的sound标签内内容长度/2
|
||||||
|
if sounds := regexpSoundSpan.FindStringSubmatch(printMsg.Content); len(sounds) > 0 {
|
||||||
|
sound := sounds[1]
|
||||||
|
lenTime := time.Duration(utf8.RuneCountInString(sound)) * time.Second
|
||||||
|
time.Sleep(lenTime / 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("doPrint timeout")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Poll.AddJob(fn)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleCheckTcpHeart 检测心跳
|
||||||
|
func HandleCheckTcpHeart(t *TcpClient, key string) {
|
||||||
|
if t.TimeoutMap[key] == true {
|
||||||
|
statusTime := t.getPrintStatusTime(key)
|
||||||
|
if !utils.IsTimeZero(statusTime) {
|
||||||
|
//1分钟内没心跳判断打印机掉线了
|
||||||
|
if time.Now().Sub(statusTime) > time.Second*75 {
|
||||||
|
globals.SugarLogger.Debugf("超过一分十秒没有心跳的打印机[%s],当前心跳时间: %s ,上一次心跳时间 : %s", key, utils.Time2TimeStr(time.Now()), utils.Time2TimeStr(statusTime))
|
||||||
|
changePrinterStatus(key, printerStatusOffline)
|
||||||
|
|
||||||
|
// 链接出错,彻底删除换成
|
||||||
|
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(key)
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddrIP)
|
||||||
|
PrintObject.DelPrintObj(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
t.getClients(key).C.Close()
|
||||||
|
close(t.MsgMap[key])
|
||||||
|
close(t.CallBackMap[key])
|
||||||
|
//t.delConn(key)
|
||||||
|
t.clear(key)
|
||||||
|
|
||||||
|
// 链接出错,彻底删除换成
|
||||||
|
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(key)
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddrIP)
|
||||||
|
PrintObject.DelPrintObj(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
687
business/jxstore/event/event_tcp_utils.go
Normal file
687
business/jxstore/event/event_tcp_utils.go
Normal file
@@ -0,0 +1,687 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"net"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
heartText = "1e000f02000151" // 老版心跳
|
||||||
|
heartTextNew = "1e001a02000151" // 新版心跳
|
||||||
|
printText = "1e00180200" // 老版打印回调
|
||||||
|
printTextNew = "1e00190200" // 新版打印回调
|
||||||
|
printSuccessText = "1e001802000150" // 老版消息打印
|
||||||
|
printSuccessTextNew = "1e001902000150" // 新版消息打印
|
||||||
|
|
||||||
|
printErrWithoutPaper = "05"
|
||||||
|
|
||||||
|
printMsgAlreadySend = 2 //已经发出打印消息
|
||||||
|
printMsgSuccess = 1 //打印成功
|
||||||
|
PrintMsgWait = 0 //待打印
|
||||||
|
printMsgFail = -1 //打印失败(打印机报出)
|
||||||
|
printMsgErr = -2 //京西报出
|
||||||
|
PrintMsgAlreadyLoad = 3 //已放入队列
|
||||||
|
|
||||||
|
heartErrNormal = "00" //正常
|
||||||
|
heartErrWithoutPaper = "04" //心跳错,缺纸
|
||||||
|
heartErrHot = "08" //过热
|
||||||
|
|
||||||
|
printerStatusOnlineWithoutPaper = 2 //在线缺纸
|
||||||
|
printerStatusOnline = 1 //在线
|
||||||
|
printerStatusOffline = -1 //离线
|
||||||
|
printerStatusOfflineAll = -9 //其他异常状态
|
||||||
|
|
||||||
|
PrintSoundMaxNumber = 16 // 十六进制最大补位
|
||||||
|
PlaceFillingParam = "0" // 补位参数
|
||||||
|
)
|
||||||
|
|
||||||
|
//标签
|
||||||
|
const (
|
||||||
|
signBR = "<br>" //换行
|
||||||
|
signCenter = "<center>" //居中
|
||||||
|
signLeft = "<left>" //居左
|
||||||
|
signRight = "<right>" //居右
|
||||||
|
signBig = "<b>" //字体放大
|
||||||
|
signHighBig = "<hb>" //字体纵向放大
|
||||||
|
signWideBig = "<wb>" //字体横向放大
|
||||||
|
signQrCenter = "<qrc>" //二维码居中
|
||||||
|
signQrLeft = "<qrl>" //二维码居左
|
||||||
|
signQrRight = "<qrr>" //二维码居右
|
||||||
|
signSound, signSoundEnd = "<sound>", "</sound>" // 声音结束标签
|
||||||
|
|
||||||
|
// GPRS通讯说明,打印机识别二进制码
|
||||||
|
hexSignBROrEXE = "0a" // 换行
|
||||||
|
hexSignCenter = "1b6101" // 居中打印
|
||||||
|
hexSignLeft = "1b6100" // 恢复居左打印
|
||||||
|
hexSignRight = "1b6102" // 居右打印
|
||||||
|
hexSignNormal = "1b2100"
|
||||||
|
hexSignBig = "1b2130" // 横向及纵向都放大
|
||||||
|
hexSignHighBig = "1b2110" // 倍高
|
||||||
|
hexSignWideBig = "1b2120" // 倍宽
|
||||||
|
hexSignQrCenter = "1d5802" // 二维码居中
|
||||||
|
hexSignQrLeft = "1d5800" // 二维码居左
|
||||||
|
hexSignQrRight = "1d5804" // 二维码居右
|
||||||
|
hexSignQr = "1b5a000106" // "1b5a000106" 0600 : 后面二维码的字节数
|
||||||
|
hexSignQrEnd = "000a1b40" // 000a0a0a1b40
|
||||||
|
hexSignSound = "1d6b40" // 音频指令(自定义语音指令)
|
||||||
|
hexSignSoundSolidification = "1B594155" // 音频指令(固化指令)
|
||||||
|
|
||||||
|
//起始标签 -- 自定义标签utf8转码为gbk字符集
|
||||||
|
byteSignBR = "3c62723e" // 换行
|
||||||
|
byteSignCenter = "3c63656e7465723e" // 居中
|
||||||
|
byteSignLeft = "3c6c6566743e" // 居左
|
||||||
|
byteSignRight = "3c72696768743e" // 居右
|
||||||
|
byteSignBig = "3c623e" // 字体放大
|
||||||
|
byteSignHighBig = "3c68623e" // 字体纵向放大
|
||||||
|
byteSignWideBig = "3c77623e" // 字体横向放大
|
||||||
|
byteSignQrCenter = "3c7172633e" // 二维码居中
|
||||||
|
byteSignQrLeft = "3c71726c3e" // 二维码居左
|
||||||
|
byteSignQrRight = "3c7172723e" // 二维码居右
|
||||||
|
byteSignSound = "3c736f756e643e" // 声音
|
||||||
|
|
||||||
|
//结束标签
|
||||||
|
byteSignCenterE = "3c2f63656e7465723e" // 居中
|
||||||
|
byteSignLeftE = "3c2f6c6566743e" // 居左
|
||||||
|
byteSignRightE = "3c2f72696768743e" // 居右
|
||||||
|
byteSignBigE = "3c2f623e" // 字体放大
|
||||||
|
byteSignHighBigE = "3c2f68623e" // 字体纵向放大
|
||||||
|
byteSignWideBigE = "3c2f77623e" // 字体横向放大
|
||||||
|
byteSignQrCenterE = "3c2f7172633e" // 二维码居中
|
||||||
|
byteSignQrLeftE = "3c2f71726c3e" // 二维码居左
|
||||||
|
byteSignQrRightE = "3c2f7172723e" // 二维码居右
|
||||||
|
byteSignSoundE = "3c2f736f756e643e" // 声音
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
printErrMap = map[string]string{
|
||||||
|
printErrWithoutPaper: "打印机缺纸!",
|
||||||
|
}
|
||||||
|
|
||||||
|
signMap = map[string]string{
|
||||||
|
byteSignBR: hexSignBROrEXE,
|
||||||
|
}
|
||||||
|
|
||||||
|
regexpQrc = regexp.MustCompile(byteSignQrCenter + "(.*?)" + byteSignQrCenterE)
|
||||||
|
regexpQrl = regexp.MustCompile(byteSignQrLeft + "(.*?)" + byteSignQrLeftE)
|
||||||
|
regexpQrr = regexp.MustCompile(byteSignQrRight + "(.*?)" + byteSignQrRightE)
|
||||||
|
regexpSound = regexp.MustCompile(byteSignSound + "(.*?)" + byteSignSoundE)
|
||||||
|
regexpSoundSpan = regexp.MustCompile(signSound + "(.*?)" + signSoundEnd)
|
||||||
|
)
|
||||||
|
|
||||||
|
type PrintInfo struct {
|
||||||
|
C net.Conn
|
||||||
|
Status int // 2 //在线缺纸 1 //在线 -1 //离线
|
||||||
|
StatusTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
//type PrintPoolMap struct {
|
||||||
|
// *sync.RWMutex
|
||||||
|
// PrintObj *TcpClient
|
||||||
|
//}
|
||||||
|
|
||||||
|
//连接的客户端,吧每个客户端都放进来
|
||||||
|
type TcpClient struct {
|
||||||
|
Clients map[string]*PrintInfo //放tcp连接的,printNo 为key
|
||||||
|
MsgMap map[string]chan *model.PrintMsg //放打印信息的,printNo为key
|
||||||
|
CallBackMap map[string]chan string //放打印信息回调信息的,printNo为key
|
||||||
|
TimeoutMap map[string]bool //退出channel
|
||||||
|
*sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPrintStatus struct {
|
||||||
|
PrintNo string //打印机编号
|
||||||
|
AppID int
|
||||||
|
}
|
||||||
|
|
||||||
|
//从连接池删除,并关闭连接
|
||||||
|
func (t *TcpClient) delConn(key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
if t.Clients[key].C != nil {
|
||||||
|
globals.SugarLogger.Debugf("-------close2 := %s", key)
|
||||||
|
t.Clients[key].C.Close()
|
||||||
|
}
|
||||||
|
delete(t.Clients, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) clear(key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
t.Clients[key].C.Close()
|
||||||
|
delete(t.Clients, key)
|
||||||
|
close(t.MsgMap[key])
|
||||||
|
delete(t.MsgMap, key)
|
||||||
|
close(t.CallBackMap[key])
|
||||||
|
delete(t.CallBackMap, key)
|
||||||
|
delete(t.TimeoutMap, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加到连接池中
|
||||||
|
func addConn(c net.Conn, t *TcpClient, key string, status int) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
t.Clients[key] = &PrintInfo{
|
||||||
|
C: c,
|
||||||
|
Status: status,
|
||||||
|
StatusTime: time.Now(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) buildMsgMap(key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
dataChan := make(chan *model.PrintMsg, 1024)
|
||||||
|
t.MsgMap[key] = dataChan
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) buildCallBackMap(key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
dataChan := make(chan string, 1024)
|
||||||
|
t.CallBackMap[key] = dataChan
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) buildTimeoutMap(key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
//dataChan := make(chan bool)
|
||||||
|
//t.TimeoutMap[key] = dataChan
|
||||||
|
t.TimeoutMap[key] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) getTimeOut(key string) bool {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
//return <-t.TimeoutMap[key]
|
||||||
|
return t.TimeoutMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildAllMap(t *TcpClient, key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
t.MsgMap[key] = make(chan *model.PrintMsg, 1024)
|
||||||
|
t.CallBackMap[key] = make(chan string, 1024)
|
||||||
|
t.TimeoutMap[key] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func BuildAllMap(t *TcpClient, key string) {
|
||||||
|
buildAllMap(t, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) getPrintStatus(key string) int {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.Clients[key] != nil {
|
||||||
|
return t.Clients[key].Status
|
||||||
|
} else {
|
||||||
|
return printerStatusOfflineAll
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) getPrintConn(key string) net.Conn {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.Clients[key] != nil {
|
||||||
|
return t.Clients[key].C
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) getPrintStatusTime(key string) time.Time {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.Clients[key] != nil {
|
||||||
|
return t.Clients[key].StatusTime
|
||||||
|
} else {
|
||||||
|
return utils.ZeroTimeValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取连接对象
|
||||||
|
func (t *TcpClient) getClients(key string) *PrintInfo {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
return t.Clients[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) isExistMsg(key string) bool {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.MsgMap[key] == nil {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) isExistCallback(key string) bool {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.CallBackMap[key] == nil {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) isExist(key string) bool {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.Clients[key] == nil {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) setPrintStatus(key string, status int) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
if t.Clients[key] != nil {
|
||||||
|
t.Clients[key].Status = status
|
||||||
|
//t.Clients[key].StatusTime = time.Now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) setPrintStatusTime(key string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
if t.Clients[key] != nil {
|
||||||
|
//t.Clients[key].Status = status
|
||||||
|
t.Clients[key].StatusTime = time.Now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) addMsgChan(printMsg *model.PrintMsg) (err error) {
|
||||||
|
t.Lock()
|
||||||
|
defer func() {
|
||||||
|
t.Unlock()
|
||||||
|
if r := recover(); r != nil && r.(error).Error() == "send on closed channel" {
|
||||||
|
err = fmt.Errorf("send on closed channel")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if t.MsgMap[printMsg.PrintNo] == nil {
|
||||||
|
dataChan := make(chan *model.PrintMsg, 1024)
|
||||||
|
t.MsgMap[printMsg.PrintNo] = dataChan
|
||||||
|
}
|
||||||
|
t.MsgMap[printMsg.PrintNo] <- printMsg
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) addCallbackChan(key, data string) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
if t.CallBackMap[key] == nil {
|
||||||
|
dataChan := make(chan string, 1024)
|
||||||
|
t.CallBackMap[key] = dataChan
|
||||||
|
}
|
||||||
|
t.CallBackMap[key] <- data
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) GetCallbackChan(key string) string {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
if t.CallBackMap[key] == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return <-t.CallBackMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTcpClient() *TcpClient {
|
||||||
|
t := &TcpClient{
|
||||||
|
Clients: make(map[string]*PrintInfo),
|
||||||
|
CallBackMap: make(map[string]chan string),
|
||||||
|
MsgMap: make(map[string]chan *model.PrintMsg),
|
||||||
|
TimeoutMap: make(map[string]bool, 0),
|
||||||
|
}
|
||||||
|
t.RWMutex = new(sync.RWMutex)
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
func printStatus2JxStatus(printStatus string) (status int) {
|
||||||
|
if printStatus == heartErrWithoutPaper {
|
||||||
|
return printerStatusOnlineWithoutPaper
|
||||||
|
} else if printStatus == heartErrNormal {
|
||||||
|
return printerStatusOnline
|
||||||
|
}
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCallbackMsgInfo(data string) (orderNo int64, printNo string) {
|
||||||
|
orderNo = h8l82int(data[len(data)-6:len(data)-4], data[len(data)-4:len(data)-2])
|
||||||
|
printNoData, _ := hex.DecodeString(data[len(printSuccessText) : len(data)-6])
|
||||||
|
printNo = string(printNoData)
|
||||||
|
return orderNo, printNo
|
||||||
|
}
|
||||||
|
|
||||||
|
func changePrinterStatus(printNo string, status int) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
if printer, err := dao.GetPrinter(db, printNo); err == nil && printer != nil {
|
||||||
|
var feilds []string
|
||||||
|
if printer.Status != status {
|
||||||
|
printer.Status = status
|
||||||
|
feilds = append(feilds, "Status")
|
||||||
|
}
|
||||||
|
isOnline := 0
|
||||||
|
if status == printerStatusOnline || status == printerStatusOnlineWithoutPaper {
|
||||||
|
isOnline = model.YES
|
||||||
|
} else {
|
||||||
|
isOnline = model.NO
|
||||||
|
printer.OfflineCount++
|
||||||
|
feilds = append(feilds, "OfflineCount")
|
||||||
|
}
|
||||||
|
if isOnline != printer.IsOnline {
|
||||||
|
printer.IsOnline = isOnline
|
||||||
|
feilds = append(feilds, "IsOnline")
|
||||||
|
}
|
||||||
|
if len(feilds) > 0 {
|
||||||
|
dao.UpdateEntity(db, printer, feilds...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//按打印机方提供的文档来的
|
||||||
|
func buildMsg(printMsg *model.PrintMsg) (data []byte, err error) {
|
||||||
|
var (
|
||||||
|
content = printMsg.Content
|
||||||
|
orderNo = printMsg.OrderNo
|
||||||
|
str = "1e"
|
||||||
|
const1 = "0200ff50"
|
||||||
|
printInit = "1b40" //打印机初始化
|
||||||
|
//voice = "1d6b401dfd001a01015b7631365d736f756e64622cc4fad3d0d0c2b6a9b5a5c0b1" //语音,中国
|
||||||
|
//qr = "1d58021b5a0001061600747470733a2f2f7777772e62616964752e636f6d2f1b000A0A0A1B40"
|
||||||
|
orderNoHexH, orderNoHexL, printData string
|
||||||
|
)
|
||||||
|
//写入数据
|
||||||
|
no, err := strconv.ParseInt(orderNo, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debug("order_msg Order_no 转换异常")
|
||||||
|
}
|
||||||
|
orderNoHexH, orderNoHexL = int2h8l8(no)
|
||||||
|
// 将数据与模板组装
|
||||||
|
if strings.Contains(content, "•") {
|
||||||
|
content = strings.ReplaceAll(content, "•", "-")
|
||||||
|
}
|
||||||
|
printDataGBK, _ := jxutils.Utf8ToGbk([]byte(utils.FilterEmoji(content)))
|
||||||
|
printData = hex.EncodeToString(printDataGBK)
|
||||||
|
printData = replaceContent(printData, printMsg)
|
||||||
|
lenData := int64(len(str) + len(const1) + len(orderNoHexH) + len(orderNoHexL) + len(printInit) + 2 + 4 + len(printData))
|
||||||
|
x1, x2 := int2h8l8(lenData / 2)
|
||||||
|
dataStr := str + x1 + x2 + const1 + orderNoHexH + orderNoHexL + printInit + printData
|
||||||
|
check := getCheckSum(dataStr)
|
||||||
|
return jxutils.Hextob(dataStr + check), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCheckSum(str string) (check string) {
|
||||||
|
var sum int64
|
||||||
|
for i := 0; i < len(str); i = i + 2 {
|
||||||
|
b := string(str[i]) + string(str[i+1])
|
||||||
|
bt, _ := strconv.ParseInt(b, 16, 32)
|
||||||
|
sum += bt
|
||||||
|
}
|
||||||
|
_, check = int2h8l8(sum)
|
||||||
|
return check
|
||||||
|
}
|
||||||
|
|
||||||
|
//内容中的标签替换成指令
|
||||||
|
func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
|
||||||
|
var (
|
||||||
|
lenqr int
|
||||||
|
hexLenqr string
|
||||||
|
)
|
||||||
|
result = content
|
||||||
|
for k, v := range signMap {
|
||||||
|
if strings.Contains(result, k) {
|
||||||
|
result = strings.ReplaceAll(result, k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 居中标签
|
||||||
|
if strings.Contains(result, byteSignCenter) && strings.Contains(result, byteSignCenterE) {
|
||||||
|
result = strings.ReplaceAll(result, byteSignCenter, hexSignCenter)
|
||||||
|
result = strings.ReplaceAll(result, byteSignCenterE, hexSignBROrEXE+hexSignLeft)
|
||||||
|
}
|
||||||
|
// 居左标签
|
||||||
|
if strings.Contains(result, byteSignLeft) && strings.Contains(result, byteSignLeftE) {
|
||||||
|
result = strings.ReplaceAll(result, byteSignLeft, hexSignLeft)
|
||||||
|
result = strings.ReplaceAll(result, byteSignLeftE, hexSignBROrEXE+hexSignLeft)
|
||||||
|
}
|
||||||
|
// 居右标签
|
||||||
|
if strings.Contains(result, byteSignRight) && strings.Contains(result, byteSignRightE) {
|
||||||
|
result = strings.ReplaceAll(result, byteSignRight, hexSignRight)
|
||||||
|
result = strings.ReplaceAll(result, byteSignRightE, hexSignBROrEXE+hexSignLeft)
|
||||||
|
}
|
||||||
|
// 字体放大
|
||||||
|
if strings.Contains(result, byteSignBig) && strings.Contains(result, byteSignBigE) {
|
||||||
|
result = strings.ReplaceAll(result, byteSignBig, hexSignBig)
|
||||||
|
result = strings.ReplaceAll(result, byteSignBigE, hexSignBROrEXE+hexSignNormal)
|
||||||
|
}
|
||||||
|
// 字体高大
|
||||||
|
if strings.Contains(result, byteSignHighBig) && strings.Contains(result, byteSignHighBigE) {
|
||||||
|
result = strings.ReplaceAll(result, byteSignHighBig, hexSignHighBig)
|
||||||
|
result = strings.ReplaceAll(result, byteSignHighBigE, hexSignBROrEXE+hexSignNormal)
|
||||||
|
}
|
||||||
|
// 字体宽大
|
||||||
|
if strings.Contains(result, byteSignWideBig) && strings.Contains(result, byteSignWideBigE) {
|
||||||
|
result = strings.ReplaceAll(result, byteSignWideBig, hexSignWideBig)
|
||||||
|
result = strings.ReplaceAll(result, byteSignWideBigE, hexSignBROrEXE+hexSignNormal)
|
||||||
|
}
|
||||||
|
// 二维码居中
|
||||||
|
if strings.Contains(result, byteSignQrCenter) && strings.Contains(result, byteSignQrCenterE) {
|
||||||
|
if qrs := regexpQrc.FindStringSubmatch(result); len(qrs) > 0 {
|
||||||
|
lenqr = len(qrs[1]) / 2
|
||||||
|
hexLenqr = fmt.Sprintf("%x", lenqr)
|
||||||
|
if len(hexLenqr) < 2 {
|
||||||
|
hexLenqr = "0" + hexLenqr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = strings.ReplaceAll(result, byteSignQrCenter, hexSignQrCenter+hexSignQr+hexLenqr+"00")
|
||||||
|
result = strings.ReplaceAll(result, byteSignQrCenterE, hexSignQrEnd)
|
||||||
|
}
|
||||||
|
// 二维码局左
|
||||||
|
if strings.Contains(result, byteSignQrLeft) && strings.Contains(result, byteSignQrLeftE) {
|
||||||
|
if qrs := regexpQrl.FindStringSubmatch(result); len(qrs) > 0 {
|
||||||
|
lenqr = len(qrs[1]) / 2
|
||||||
|
hexLenqr = fmt.Sprintf("%x", lenqr)
|
||||||
|
if len(hexLenqr) < 2 {
|
||||||
|
hexLenqr = "0" + hexLenqr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = strings.ReplaceAll(result, byteSignQrLeft, hexSignQrLeft+hexSignQr+hexLenqr+"00")
|
||||||
|
result = strings.ReplaceAll(result, byteSignQrLeftE, hexSignQrEnd)
|
||||||
|
}
|
||||||
|
// 二维码居右
|
||||||
|
if strings.Contains(result, byteSignQrRight) && strings.Contains(result, byteSignQrRightE) {
|
||||||
|
if qrs := regexpQrr.FindStringSubmatch(result); len(qrs) > 0 {
|
||||||
|
lenqr = len(qrs[1])
|
||||||
|
hexLenqr = fmt.Sprintf("%x", lenqr)
|
||||||
|
if len(hexLenqr) < 2 {
|
||||||
|
hexLenqr = "0" + hexLenqr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = strings.ReplaceAll(result, byteSignQrRight, hexSignQrRight+hexSignQr+hexLenqr+"00")
|
||||||
|
result = strings.ReplaceAll(result, byteSignQrRightE, hexSignQrEnd)
|
||||||
|
}
|
||||||
|
// 固定模板输出语音
|
||||||
|
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
|
||||||
|
var soundStr []string
|
||||||
|
for _, v1 := range strings.Split(result, byteSignSoundE) {
|
||||||
|
v1 += byteSignSoundE
|
||||||
|
if sounds := regexpSound.FindStringSubmatch(v1); len(sounds) > 0 {
|
||||||
|
sound := sounds[1]
|
||||||
|
// 将语音包转换为十六进制
|
||||||
|
voice := ""
|
||||||
|
for _, v := range strings.Split(sound, "2c") {
|
||||||
|
voice += hexSignSoundSolidification
|
||||||
|
soundNum, _ := hex.DecodeString(v) // 十六进制转字符串
|
||||||
|
intSound, _ := strconv.ParseInt(string(soundNum), 10, 64)
|
||||||
|
int16Sound := strconv.FormatInt(intSound, 16)
|
||||||
|
if intSound < PrintSoundMaxNumber { // 小于十六补位
|
||||||
|
voice += PlaceFillingParam + int16Sound
|
||||||
|
} else {
|
||||||
|
voice += int16Sound
|
||||||
|
}
|
||||||
|
}
|
||||||
|
soundStr = append(soundStr, voice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = strings.ReplaceAll(result, byteSignSound, "*")
|
||||||
|
result = strings.ReplaceAll(result, byteSignSoundE, "&")
|
||||||
|
for i := 0; i < len(soundStr); i++ {
|
||||||
|
start := strings.Index(result, "*")
|
||||||
|
end := strings.Index(result, "&")
|
||||||
|
result = strings.Replace(result, result[start:end+1], soundStr[i], 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 自动合成语音功能
|
||||||
|
//if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
|
||||||
|
// if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {
|
||||||
|
// sound := sounds[1]
|
||||||
|
// if printer, _ := dao.GetPrinter(dao.GetDB(), printMsg.PrintNo); printer != nil {
|
||||||
|
// //先把结束标签消了
|
||||||
|
// result = strings.ReplaceAll(result, byteSignSoundE, "")
|
||||||
|
// soundPrefix := ""
|
||||||
|
// if printer.Sound != "" {
|
||||||
|
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
|
||||||
|
// } else {
|
||||||
|
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
|
||||||
|
// }
|
||||||
|
// hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
|
||||||
|
// hexPrefixStr := hex.EncodeToString(hexPrefix)
|
||||||
|
// realSound := hexPrefixStr + sound
|
||||||
|
// allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)
|
||||||
|
// if len(allLen) < 2 {
|
||||||
|
// allLen = "0" + allLen
|
||||||
|
// }
|
||||||
|
// soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2))
|
||||||
|
// result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkPrintMsg(db *dao.DaoDB, printMsg *model.PrintMsg) (err error) {
|
||||||
|
if printMsg.Content == "" {
|
||||||
|
return fmt.Errorf("此打印信息内容为空!printMsg printNo:[%v], orderNo :[%v] 1", printMsg.PrintNo, printMsg.OrderNo)
|
||||||
|
}
|
||||||
|
if printMsg.PrintNo == "" {
|
||||||
|
return fmt.Errorf("此打印信息打印机编号为空!printMsg printNo:[%v], orderNo :[%v] 2", printMsg.PrintNo, printMsg.OrderNo)
|
||||||
|
}
|
||||||
|
if printMsg.OrderNo == "" {
|
||||||
|
return fmt.Errorf("此打印信息订单序号为空!printMsg printNo:[%v], orderNo :[%v] 3", printMsg.PrintNo, printMsg.OrderNo)
|
||||||
|
}
|
||||||
|
//if printer, err := dao.GetPrinter(db, printMsg.PrintNo); err == nil {
|
||||||
|
// if printer != nil {
|
||||||
|
// if printer.FlowFlag == 1 {
|
||||||
|
// return fmt.Errorf("此打印机当月流量已用完,请及时充值!printNo:[%v]", printMsg.PrintNo)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func int2h8l8(i int64) (h, l string) {
|
||||||
|
origin2 := fmt.Sprintf("%b", i)
|
||||||
|
flag := 16 - len(origin2)
|
||||||
|
for i := 0; i < flag; i++ {
|
||||||
|
origin2 = "0" + origin2
|
||||||
|
}
|
||||||
|
begin8 := origin2[:8]
|
||||||
|
end8 := origin2[8:]
|
||||||
|
r1, _ := strconv.ParseInt(begin8, 2, 32)
|
||||||
|
r2, _ := strconv.ParseInt(end8, 2, 32)
|
||||||
|
h = fmt.Sprintf("%x", r1)
|
||||||
|
l = fmt.Sprintf("%x", r2)
|
||||||
|
if len(h)%2 != 0 {
|
||||||
|
h = "0" + h
|
||||||
|
}
|
||||||
|
if len(l)%2 != 0 {
|
||||||
|
l = "0" + l
|
||||||
|
}
|
||||||
|
return h, l
|
||||||
|
}
|
||||||
|
|
||||||
|
func h8l82int(h, l string) (i int64) {
|
||||||
|
s1, s2 := xtob(h), xtob(l)
|
||||||
|
flag1 := 8 - len(s1)
|
||||||
|
flag2 := 8 - len(s2)
|
||||||
|
for m := 0; m < flag1; m++ {
|
||||||
|
s1 = "0" + s1
|
||||||
|
}
|
||||||
|
for j := 0; j < flag2; j++ {
|
||||||
|
s2 = "0" + s2
|
||||||
|
}
|
||||||
|
i, _ = strconv.ParseInt(s1+s2, 2, 32)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
func xtob(x string) string {
|
||||||
|
base, _ := strconv.ParseInt(x, 16, 10)
|
||||||
|
return strconv.FormatInt(base, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Heartbeat 心跳回调
|
||||||
|
func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string, printRemoteAddr string) {
|
||||||
|
//printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8])
|
||||||
|
//printNo = string(printNoData)
|
||||||
|
status := printStatus2JxStatus(data[len(data)-8 : len(data)-6])
|
||||||
|
//如果没在连接池里
|
||||||
|
//1、加到连接池中,不同的打印机no开不同的goroutine
|
||||||
|
//2、初始化channel,每个打印机一个,放打印消息和打印回调消息
|
||||||
|
//3、读数据库里的待打印信息,放到打印channel中
|
||||||
|
//4、读打印channel并打印,并切等待回调channel中的消息
|
||||||
|
//5、修改数据库中打印机状态(没在连接池中说明是重新连接的)
|
||||||
|
//6、监听心跳时间,超过1分多钟就clear掉
|
||||||
|
if t.getClients(printNo) == nil || t == nil || t.getPrintStatusTime(printNo).IsZero() || time.Now().Sub(t.Clients[printNo].StatusTime).Seconds() >= 120 {
|
||||||
|
addConn(c, t, printNo, status)
|
||||||
|
buildAllMap(t, printNo)
|
||||||
|
//t.TimeoutMap[printNo] <- true
|
||||||
|
HandleTcpMessages(t, printNo)
|
||||||
|
doPrint(t, printNo)
|
||||||
|
if status == printerStatusOnline {
|
||||||
|
//t.printFail()
|
||||||
|
}
|
||||||
|
//changePrinterStatus(printNo, status)
|
||||||
|
// todo 暂时关闭心跳检测
|
||||||
|
HandleCheckTcpHeart(t, printNo)
|
||||||
|
// todo 证明打印机已经被激活,将激活打印机存入数据库,保证用户不能无限制绑定打印机
|
||||||
|
if err := dao.NotExistsCreate(printNo); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("监听打印机心跳,不存在则创建 :[%v],printNo[%s]", err, printNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintObject.SetPrintObj(printNo, t)
|
||||||
|
PrintAddrAndIp.SetPrintAddrAndIp(printRemoteAddr, printNo)
|
||||||
|
PrintIpAndAddr.SetPrintIpAndAddr(printNo, printRemoteAddr)
|
||||||
|
} else {
|
||||||
|
//在加到连接池中已经更新了时间,所以放在else里
|
||||||
|
t.setPrintStatusTime(printNo)
|
||||||
|
}
|
||||||
|
//状态不一致再更新状态(可能缺纸了,过热了等)
|
||||||
|
t.setPrintStatus(printNo, status)
|
||||||
|
changePrinterStatus(printNo, status)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callback 打印成功回调
|
||||||
|
func Callback(c net.Conn, t *TcpClient, data string, printNo string) {
|
||||||
|
//打印消息发送后,打印机会回调该条打印消息的状态(打印成功or失败,失败原因..)
|
||||||
|
//将回调的信息放到回调channel中,打印成功后再打印下一条消息
|
||||||
|
//_, printNo = getCallbackMsgInfo(data)
|
||||||
|
//更新打印机心跳时间(打印机本身不会在打印的同时,或回调的同时发心跳消息,会导致心跳判断超时,这里更新一下)
|
||||||
|
t.setPrintStatusTime(printNo)
|
||||||
|
t.addCallbackChan(printNo, data)
|
||||||
|
}
|
||||||
117
business/jxstore/event/print_test.go
Normal file
117
business/jxstore/event/print_test.go
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPrintMsg(t *testing.T) {
|
||||||
|
|
||||||
|
msg := &model.PrintMsg{
|
||||||
|
ModelIDCULD: model.ModelIDCULD{},
|
||||||
|
PrintNo: "120220915001069",
|
||||||
|
Content: "<left><hb>客户地址:瑞小满颐园 (瑞小满•颐园正门 门卫大叔 就可以 拍照反馈 辛苦谢谢)@#四川省成都市金牛区天回镇街道瑞小满•熊猫颐园</hb></left>",
|
||||||
|
OrderNo: "12", // 2147483648111
|
||||||
|
Status: 0,
|
||||||
|
Comment: "",
|
||||||
|
MsgID: "20221216175529_09440117",
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := buildMsg(msg)
|
||||||
|
|
||||||
|
fmt.Println("data=", string(data))
|
||||||
|
fmt.Println("err=", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 十六进制转字符串
|
||||||
|
func TestDC(t *testing.T) {
|
||||||
|
str := "093c736f756e643e323009091b61011b2130bea9cef7b9fbd4b00a1b21000a1b61000a0a09091b6101cad6bbfac2f2b2cbc9cfbea9cef70a1b61000a1b6101bcabcbd9b5bdbcd2cbcdbeaacfb20a1b61000a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0acfc2b5a5cab1bce43a20323032312d30382d32372032313a35373a32360ad4a4bcc6cbcdb4ef3a20323032312d30382d32372032323a35373a32360ab6a9b5a5b1e0bac53a2039333135343434313733303231313130300a0a1b2130c3c0cdc5cde2c2f42331390a1b21000a1d58021b5a00010611003933313534343431373330323131313030000a1b400abfcdbba73a20c0eeb4f3c3ce28cfc8c9fa290ab5e7bbb03a2031353938373230303334300ab5d8d6b73a20b1b1c6d6ceb0d2b5b9e3b3a12d32bac5c2a52028ceb0d2b5b9e3b3a142c7f8294023d4c6c4cfcaa1b3fed0dbd2cdd7e5d7d4d6ced6ddb3fed0dbcad0c2b9b3c7d5f2ceb0d2b5b9e3b3a10a0abfcdbba7b1b8d7a23a200a1b2130a1bec8e7d3f6c8b1bbf5a1bfa3ba20c8b1bbf5cab1b5e7bbb0d3ebced2b9b5cda80a1b21000a0a0ac9ccc6b7c3f7cfb83a200ac6b7c3fb20202020cafdc1bf20202020b5a5bcdb20202020202020d0a1bcc60a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0aa1bed7d4d3c9c6b4a1bfcfb4bebbbaeccce1313630672fbad00a20202020202078312020202020a3a4392e32302020202020a3a4392e32300aa1beb9fbc7d0a1bf20c5a3c4ccc4beb9cfd4bc333030672fb7dd0a20202020202078312020202020a3a4392e37302020202020a3a4392e37300aa1bed7d4d3c9c6b4a1bfd1cfd1a1cfe3bdb6b9fbc7d0313830672fbad00a20202020202078312020202020a3a4382e38302020202020a3a4382e38300a5bcdf8baecb9fbc7d05dcedac3b7d0a1b7acc7d13235672fb8f60a20202020207831302020202020a3a4302e38302020202020a3a4382e30300a5bcfd6b0fe5dccf0caafc1f1d7d1d4bc323530672fb7dd2831b8f6290a20202020202078312020202020a3a4332e35302020202020a3a4332e35300aa1beb1acc6b7ccd8bbdda1bfd0c2cfcab4e0ccf0b0ebbdefb9fec3dcb9cf20b9fec3dbb9cfb9fbc7d0d2bbbad0323530672fbad0283233307e32363067290a20202020202078312020202020a3a4302e30312020202020a3a4302e30310aa1beb1acc6b7ccd8bbdda1bfd0c2cfcab4e0ccf0b0ebbdefb9fec3dcb9cf20b9fec3dbb9cfb9fbc7d0d2bbbad0323530672fbad0283233307e32363067290a20202020202078312020202020a3a4382e36302020202020a3a4382\ne36300a0ab9b237d6d63136bcfec9ccc6b70a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0a1b61011b2110c9ccc6b7d6cac1bfcecacce2c7ebc1aacfb53a0a1b21000a1b61000a1b61011b2110bea9cef7b9fbd4b0a1a4b9fbc7d0a1a4cbaeb9fbc0cca3a8b9fbb9fbceddb5eaa3a93a31353834313031313339370a1b21000a1b61000a0ab8fcb6e0d0c5cfa2c7ebb9d8d7a2b9d9b7bdcea2d0c53a20bea9cef7b2cbcad00a0a0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0a0a0a"
|
||||||
|
str2, _ := hex.DecodeString(str)
|
||||||
|
fmt.Println(string(str2))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 十进制字符串转十六进制
|
||||||
|
func Test10Two16(t *testing.T) {
|
||||||
|
//fmt.Println(strconv.FormatInt(11, 16)) // 2 to 10
|
||||||
|
//for _, v := range strings.Split("324c", "d") {
|
||||||
|
// fmt.Println(v)
|
||||||
|
//}
|
||||||
|
hexPrefix, _ := jxutils.Utf8ToGbk([]byte("[8]sounda14"))
|
||||||
|
hexPrefixStr := hex.EncodeToString(hexPrefix)
|
||||||
|
fmt.Println(hexPrefixStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCheckSum(t *testing.T) {
|
||||||
|
soundNum, _ := hex.DecodeString("3130") // 十六进制转字符串
|
||||||
|
intSound, _ := strconv.ParseInt(string(soundNum), 10, 64)
|
||||||
|
int16Sound := strconv.FormatInt(intSound, 16)
|
||||||
|
b := strconv.FormatInt(16, 16)
|
||||||
|
if int16Sound < b {
|
||||||
|
fmt.Println("111111")
|
||||||
|
} else {
|
||||||
|
fmt.Println("22222")
|
||||||
|
}
|
||||||
|
fmt.Println("==========", int16Sound)
|
||||||
|
fmt.Println("======2====", utf8.RuneCountInString("64,65,66"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTen216(t *testing.T) {
|
||||||
|
aa := `
|
||||||
|
3c736f756e643e
|
||||||
|
312c322c33
|
||||||
|
3c2f736f756e643e
|
||||||
|
1b6101bed3d6d0cec4d7d60a1b6100
|
||||||
|
3c736f756e643e
|
||||||
|
342c352c36
|
||||||
|
3c2f736f756e643e
|
||||||
|
1b6101bed3d6d00a1b6100
|
||||||
|
`
|
||||||
|
bb := `1B59415501 1B59415502 1B59415503`
|
||||||
|
kk := `1B59415501 1B59415502 1B59415503 1b6101bed3d6d0cec4d7d60a1b6100 1b6101bed3d6d0cec4d7d60a1b6100 1B59415504 1B59415505 1B59415506 1b6101bed3d6d00a1b6100`
|
||||||
|
// 第一个语音字段
|
||||||
|
index1 := strings.Index(aa, "3c736f756e643e")
|
||||||
|
index2 := strings.Index(aa, "3c2f736f756e643e")
|
||||||
|
str := aa[index1:index2]
|
||||||
|
gg := strings.Replace(aa, str, bb, 1)
|
||||||
|
fmt.Println(gg)
|
||||||
|
fmt.Println(kk)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewPool(t *testing.T) {
|
||||||
|
var pool = NewPool(100)
|
||||||
|
pool.Start()
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
num := i
|
||||||
|
pool.AddJob(func() {
|
||||||
|
fmt.Printf("Worker %d: %d is odd? %v\n", num%5, num, num%2 == 1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
pool.AddJob(func() {
|
||||||
|
fmt.Println("刘磊")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pool.Wait()
|
||||||
|
pool.Stop()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCC(t *testing.T) {
|
||||||
|
var aa map[string]string
|
||||||
|
|
||||||
|
aa = make(map[string]string, 10)
|
||||||
|
fmt.Println(aa)
|
||||||
|
aa["1"] = "2"
|
||||||
|
c, d := aa["1"]
|
||||||
|
fmt.Println(c)
|
||||||
|
fmt.Println(d)
|
||||||
|
}
|
||||||
104
business/jxstore/event/timing_task.go
Normal file
104
business/jxstore/event/timing_task.go
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Poll *Pool
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Poll = NewPool(500)
|
||||||
|
Poll.Start()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Job func()
|
||||||
|
|
||||||
|
type Worker struct {
|
||||||
|
id int
|
||||||
|
jobChannel chan Job
|
||||||
|
quit chan bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Pool struct {
|
||||||
|
workers []*Worker
|
||||||
|
jobChannel chan Job
|
||||||
|
wg sync.WaitGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWorker(id int, jobChannel chan Job) *Worker {
|
||||||
|
return &Worker{
|
||||||
|
id: id,
|
||||||
|
jobChannel: jobChannel,
|
||||||
|
quit: make(chan bool),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Worker) Start() {
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case job := <-w.jobChannel:
|
||||||
|
job()
|
||||||
|
case <-w.quit:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Worker) Stop() {
|
||||||
|
w.quit <- true
|
||||||
|
close(w.quit)
|
||||||
|
//go func() {
|
||||||
|
// w.quit <- true
|
||||||
|
//}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPool(numWorkers int) *Pool {
|
||||||
|
jobChannel := make(chan Job)
|
||||||
|
pool := &Pool{
|
||||||
|
workers: make([]*Worker, numWorkers),
|
||||||
|
jobChannel: jobChannel,
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < numWorkers; i++ {
|
||||||
|
worker := NewWorker(i, jobChannel)
|
||||||
|
pool.workers[i] = worker
|
||||||
|
}
|
||||||
|
|
||||||
|
return pool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pool) Start() {
|
||||||
|
for _, worker := range p.workers {
|
||||||
|
worker.Start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pool) Stop() {
|
||||||
|
for _, worker := range p.workers {
|
||||||
|
worker.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//func (p *Pool) AddJob(job Job) {
|
||||||
|
// p.wg.Add(1)
|
||||||
|
// p.jobChannel <- func() {
|
||||||
|
// job()
|
||||||
|
// p.wg.Done()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (p *Pool) AddJob(job Job) {
|
||||||
|
p.wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
p.jobChannel <- func() {
|
||||||
|
defer p.wg.Done()
|
||||||
|
job()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
func (p *Pool) Wait() {
|
||||||
|
p.wg.Wait()
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package financial
|
package financial
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -10,6 +11,18 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func AddMixPay(txDB orm.TxOrmer, orderID string, balancePrice, totalPrice, status int) error {
|
||||||
|
mixPayInfo := &model.MixPay{
|
||||||
|
OrderID: orderID,
|
||||||
|
BalancePrice: balancePrice,
|
||||||
|
TotalPrice: totalPrice,
|
||||||
|
Status: status,
|
||||||
|
WxPrice: totalPrice - balancePrice,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULEntity(mixPayInfo, jxcontext.AdminCtx.GetUserName())
|
||||||
|
return dao.CreateEntityTx(txDB, mixPayInfo)
|
||||||
|
}
|
||||||
|
|
||||||
func AddBillIncome(txDB orm.TxOrmer, billID int64, billType, incomePrice, jobID int) (err error) {
|
func AddBillIncome(txDB orm.TxOrmer, billID int64, billType, incomePrice, jobID int) (err error) {
|
||||||
billIncome := &model.BillIncome{
|
billIncome := &model.BillIncome{
|
||||||
BillID: billID,
|
BillID: billID,
|
||||||
@@ -165,3 +178,66 @@ func SettleUnionOrders(ctx *jxcontext.Context, vendorIDs []int) (err error) {
|
|||||||
dao.Commit(db, txDB)
|
dao.Commit(db, txDB)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//微信 老会员续费
|
||||||
|
func WXInvestMember(ctx *jxcontext.Context, memberID int, userID string) (errCode string, err error) {
|
||||||
|
var db = dao.GetDB()
|
||||||
|
//获取用户 当前会员信息
|
||||||
|
userMembers, err := dao.GetUserMember(db, userID, model.MemberTypeNormal)
|
||||||
|
if err != nil {
|
||||||
|
return "获取用户会员信息失败", err
|
||||||
|
}
|
||||||
|
//当前状态是否是会员 续费/开通
|
||||||
|
if len(userMembers) > 0 {
|
||||||
|
userMember := userMembers[0]
|
||||||
|
if memberID == model.OrderTypeMember {
|
||||||
|
userMember.EndAt = userMember.EndAt.AddDate(0, 1, 0)
|
||||||
|
} else {
|
||||||
|
userMember.EndAt = userMember.EndAt.AddDate(1, 0, 0)
|
||||||
|
}
|
||||||
|
if _, err = dao.UpdateEntity(db, userMember, "EndAt"); err != nil {
|
||||||
|
return "更新会员到期时间失败", err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
userMember2 := &model.UserMember{
|
||||||
|
UserID: userID,
|
||||||
|
MemberType: model.MemberTypeNormal,
|
||||||
|
MemberTypeID: memberID,
|
||||||
|
}
|
||||||
|
if memberID == model.OrderTypeMember {
|
||||||
|
userMember2.EndAt = time.Now().AddDate(0, 1, 0)
|
||||||
|
} else {
|
||||||
|
userMember2.EndAt = time.Now().AddDate(1, 0, 0)
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(userMember2, ctx.GetUserName())
|
||||||
|
if err = dao.CreateEntity(db, userMember2); err != nil {
|
||||||
|
return "开通会员失败", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//微信 新充值会员
|
||||||
|
func WXInvestMemberNew(ctx *jxcontext.Context, memberID int, userID string) (errCode string, err error) {
|
||||||
|
var db = dao.GetDB()
|
||||||
|
userMember2 := &model.UserMember{
|
||||||
|
UserID: userID,
|
||||||
|
MemberType: 1, //model.MemberTypeNormal,
|
||||||
|
MemberTypeID: 1,
|
||||||
|
}
|
||||||
|
if memberID == model.OrderTypeMember {
|
||||||
|
userMember2.EndAt = time.Now().AddDate(0, 1, 0)
|
||||||
|
} else {
|
||||||
|
userMember2.EndAt = time.Now().AddDate(1, 0, 0)
|
||||||
|
}
|
||||||
|
userinfo, err := dao.GetUser(db, userMember2.UserID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
userMember2.LastOperator = userinfo.UserID2
|
||||||
|
userMember2.DeletedAt = utils.DefaultTimeValue
|
||||||
|
if err = dao.CreateEntity(db, userMember2); err != nil {
|
||||||
|
return "开通会员失败", err
|
||||||
|
}
|
||||||
|
return errCode, err
|
||||||
|
}
|
||||||
|
|||||||
14
business/jxstore/financial/bill_test.go
Normal file
14
business/jxstore/financial/bill_test.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package financial
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOnWXPayFinished(t *testing.T) {
|
||||||
|
//var (
|
||||||
|
// ctx *jxcontext.Context
|
||||||
|
//)
|
||||||
|
//if _, err := WXInvestMember(ctx, 1, "1303D7B2096011ED9A4C525400C36BDA", true); err != nil {
|
||||||
|
// t.Logf("微信购买会员失败")
|
||||||
|
//}
|
||||||
|
}
|
||||||
@@ -34,28 +34,69 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *PayHandler) CreatePay(txDB orm.TxOrmer) (err error) {
|
func (p *PayHandler) CreatePay(txDB orm.TxOrmer, subAppID string) (err error) {
|
||||||
switch p.PayType {
|
switch p.PayType {
|
||||||
case model.PayTypeTL:
|
case model.PayTypeTL:
|
||||||
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
||||||
Trxamt: int(p.Order.PayPrice),
|
Trxamt: p.Order.PayPrice,
|
||||||
NotifyUrl: globals.TLPayNotifyURL,
|
NotifyUrl: globals.TLPayNotifyURL,
|
||||||
Reqsn: p.Order.OrderID,
|
Reqsn: p.Order.OrderID,
|
||||||
PayType: p.VendorPayType,
|
PayType: p.VendorPayType,
|
||||||
}
|
}
|
||||||
|
//暂时做兼容处理
|
||||||
|
if p.VendorPayType == "JSAPI" {
|
||||||
|
param.PayType = tonglianpayapi.PayTypeWxXcx
|
||||||
|
}
|
||||||
if p.VendorPayType == tonglianpayapi.PayTypeWxXcx {
|
if p.VendorPayType == tonglianpayapi.PayTypeWxXcx {
|
||||||
if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeWxApp {
|
param.SubAppID = subAppID
|
||||||
|
authInfo, err := p.Ctx.GetV2AuthInfo()
|
||||||
|
// 微信小程序支付
|
||||||
|
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
||||||
param.Acct = authInfo.GetAuthID()
|
param.Acct = authInfo.GetAuthID()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
if p.VendorPayType == tonglianpayapi.PayTypeZfbJS || p.VendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||||
if err == nil {
|
if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil {
|
||||||
|
param.Acct = authInfo.GetAuthID()
|
||||||
|
}
|
||||||
|
if param.Acct == "" {
|
||||||
|
return fmt.Errorf("未找到用户的认证ID!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if p.VendorPayType == tonglianpayapi.PayTypeH5 {
|
||||||
|
param2 := &tonglianpayapi.CreateH5UnitorderOrderParam{
|
||||||
|
Trxamt: p.Order.PayPrice,
|
||||||
|
NotifyUrl: globals.TLPayNotifyURL,
|
||||||
|
Body: "冲天猴",
|
||||||
|
Charset: "UTF-8",
|
||||||
|
}
|
||||||
|
err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
||||||
|
} else {
|
||||||
|
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var result2 tonglianpayapi.PayInfo
|
var result2 tonglianpayapi.PayInfo
|
||||||
json.Unmarshal([]byte(result.PayInfo), &result2)
|
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||||
p.Order.PrepayID = result2.Package[strings.LastIndex(result2.Package, "=")+1 : len(result2.Package)]
|
p.Order.PrepayID = result2.Package[strings.LastIndex(result2.Package, "=")+1 : len(result2.Package)]
|
||||||
p.Order.TransactionID = result.TrxID
|
p.Order.TransactionID = result.TrxID
|
||||||
_, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "TransactionID")
|
|
||||||
|
if _, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "TransactionID"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
wxPay := &WxPayParam{
|
||||||
|
Prepayid: p.Order.PrepayID,
|
||||||
|
Noncestr: result2.NonceStr,
|
||||||
|
Timestamp: utils.Int64ToStr(utils.MustInterface2Int64(result2.TimeStamp)),
|
||||||
|
Package: result2.Package,
|
||||||
|
Partnerid: "", // 商户Id
|
||||||
|
Appid: result2.AppID,
|
||||||
|
Sign: result2.PaySign,
|
||||||
|
}
|
||||||
|
p.WxPayParam = wxPay
|
||||||
}
|
}
|
||||||
|
// 暂时不支持微信直接支付
|
||||||
case model.PayTypeWX:
|
case model.PayTypeWX:
|
||||||
param := &wxpayapi.CreateOrderParam{
|
param := &wxpayapi.CreateOrderParam{
|
||||||
OutTradeNo: p.Order.OrderID,
|
OutTradeNo: p.Order.OrderID,
|
||||||
@@ -135,47 +176,49 @@ func signParam(signType string, params map[string]interface{}) (sig string) {
|
|||||||
|
|
||||||
func (p *PayHandler) CreateRefund() (err error) {
|
func (p *PayHandler) CreateRefund() (err error) {
|
||||||
switch p.PayType {
|
switch p.PayType {
|
||||||
case model.PayTypeTL:
|
case model.PayTypeTL: // 收费贵,不适用
|
||||||
case model.PayTypeWX:
|
case model.PayTypeAliPay: // 支付宝支付
|
||||||
|
|
||||||
|
case model.PayTypeWX: // 需要保持账号每天有交易流水,不适用
|
||||||
//企业付款(提现)
|
//企业付款(提现)
|
||||||
if p.VendorPayType == model.VendorPayTypeCompanyPay {
|
if p.VendorPayType == model.VendorPayTypeCompanyPay {
|
||||||
// param := &wxpayapi.TransfersParam{
|
param := &wxpayapi.TransfersParam{
|
||||||
// PartnerTradeNo: p.Order.OrderID,
|
PartnerTradeNo: p.Order.OrderID,
|
||||||
// CheckName: wxpayapi.CheckName,
|
CheckName: wxpayapi.CheckName,
|
||||||
// Desc: "冲天猴儿app提现到账",
|
Desc: "冲天猴儿app提现到账",
|
||||||
// SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
||||||
// }
|
}
|
||||||
// //1元以下免费,以上收取对应城市手续费
|
//1元以下免费,以上收取对应城市手续费
|
||||||
// place, err := dao.GetPlaceByCode(dao.GetDB(), p.Order.CityCode)
|
place, err := dao.GetPlaceByCode(dao.GetDB(), p.Order.CityCode)
|
||||||
// if err != nil || place == nil {
|
if err != nil || place == nil {
|
||||||
// return fmt.Errorf("未找到该城市!code:%v", p.Order.CityCode)
|
return fmt.Errorf("未找到该城市!code:%v", p.Order.CityCode)
|
||||||
// }
|
}
|
||||||
// if p.Order.PayPrice < 100 {
|
if p.Order.PayPrice < 100 {
|
||||||
// param.Amount = p.Order.PayPrice
|
param.Amount = p.Order.PayPrice
|
||||||
// } else {
|
} else {
|
||||||
// param.Amount = p.Order.PayPrice * place.DividePercentage / 100 //手续费
|
param.Amount = p.Order.PayPrice * place.DividePercentage / 100 //手续费
|
||||||
// }
|
}
|
||||||
// if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil {
|
if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil {
|
||||||
// param.OpenID = authInfo.GetAuthID()
|
param.OpenID = authInfo.GetAuthID()
|
||||||
// }
|
}
|
||||||
// globals.SugarLogger.Debugf("CreateRefund wx param: %v", utils.Format4Output(param, false))
|
globals.SugarLogger.Debugf("CreateRefund wx param: %v", utils.Format4Output(param, false))
|
||||||
// result, err2 := payMap[p.Order.Way].Transfers(param)
|
result, err2 := payMap[p.Order.Way].Transfers(param)
|
||||||
// if err2 == nil {
|
if err2 == nil {
|
||||||
// p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
||||||
// p.Order.Comment = result.DeviceInfo
|
p.Order.Comment = result.DeviceInfo
|
||||||
// p.Order.OriginalData = utils.Format4Output(result, true)
|
p.Order.OriginalData = utils.Format4Output(result, true)
|
||||||
// if result.ReturnMsg == "" {
|
if result.ReturnMsg == "" {
|
||||||
// p.Order.Status = model.OrderStatusFinished
|
p.Order.Status = model.OrderStatusFinished
|
||||||
// } else {
|
} else {
|
||||||
// p.Order.Status = model.OrderStatusCanceled
|
p.Order.Status = model.OrderStatusCanceled
|
||||||
// }
|
}
|
||||||
// dao.UpdateEntity(dao.GetDB(), p.Order)
|
dao.UpdateEntity(dao.GetDB(), p.Order)
|
||||||
// if result.ReturnMsg == "" {
|
if result.ReturnMsg == "" {
|
||||||
// err = OnCashFinished(p.Order)
|
err = OnCashFinished(p.Order)
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// return err2
|
return err2
|
||||||
// }
|
}
|
||||||
err = OnCashFinished(p.Order)
|
err = OnCashFinished(p.Order)
|
||||||
} else if p.VendorPayType == model.VendorPayTypeTransferAccount {
|
} else if p.VendorPayType == model.VendorPayTypeTransferAccount {
|
||||||
p.Order.PayFinishedAt = time.Now()
|
p.Order.PayFinishedAt = time.Now()
|
||||||
@@ -202,7 +245,8 @@ func OnTLPayCallback(call *tonglianpayapi.CallBackResult) (err error) {
|
|||||||
|
|
||||||
func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
||||||
order := &model.Order{
|
order := &model.Order{
|
||||||
OrderID: call.CusorderID,
|
OrderID: call.CusorderID,
|
||||||
|
TransactionID: call.TrxID,
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
||||||
@@ -213,16 +257,38 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
|||||||
loc, _ := time.LoadLocation("Local")
|
loc, _ := time.LoadLocation("Local")
|
||||||
t1, _ := time.ParseInLocation("20060102150405", call.PayTime, loc)
|
t1, _ := time.ParseInLocation("20060102150405", call.PayTime, loc)
|
||||||
order.PayFinishedAt = t1
|
order.PayFinishedAt = t1
|
||||||
// order.TransactionID = call.ChnlTrxID
|
|
||||||
order.OriginalData = utils.Format4Output(call, true)
|
order.OriginalData = utils.Format4Output(call, true)
|
||||||
|
payStatus := model.PayStatusNo
|
||||||
|
//order.PayMethod = 2 // 通联微信支付
|
||||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
order.Status = model.OrderStatusFinished
|
order.Status = model.OrderStatusFinished
|
||||||
|
payStatus = model.OrderStatusSuccessPay
|
||||||
} else {
|
} else {
|
||||||
order.Status = model.OrderStatusCanceled
|
order.Status = model.OrderStatusCanceled
|
||||||
|
payStatus = model.OrderStatusFailPay
|
||||||
}
|
}
|
||||||
dao.UpdateEntity(db, order)
|
|
||||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
//充值会员 增加微信支付处理业务
|
||||||
err = OnPayFinished(order)
|
if (order.OrderType == model.OrderTypeMember || order.OrderType == model.OrderTypeMemberYear) && call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
|
return OnWXPayFinished(order)
|
||||||
|
}
|
||||||
|
// 充值话费
|
||||||
|
if order.OrderType == model.OrderTypeMobile && call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
|
return OnWxPayTelephone(order)
|
||||||
|
}
|
||||||
|
// 发快递
|
||||||
|
if order.OrderType == model.OrderTypeDelivery && call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
|
return OnWxPaySendPage(db, order, call, payStatus)
|
||||||
|
}
|
||||||
|
//需要充值到余额方式 购买的
|
||||||
|
if order.OrderType == model.OrderTypeBalance && call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
|
if err := dao.UpdateUserBill(order.UserID, order.PayPrice); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
order.Status = 110
|
||||||
|
if _, err := dao.UpdateEntity(db, order, "Status"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("onTLpayFinished msg:%s, err:%v", utils.Format4Output(call, true), err)
|
globals.SugarLogger.Debugf("onTLpayFinished msg:%s, err:%v", utils.Format4Output(call, true), err)
|
||||||
@@ -231,70 +297,52 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func onTLpayRefund(call *tonglianpayapi.CallBackResult) (err error) {
|
func onTLpayRefund(call *tonglianpayapi.CallBackResult) (err error) {
|
||||||
// orderPayRefund := &model.OrderPayRefund{
|
orderPayRefund := &model.OrderPayRefund{
|
||||||
// RefundID: call.CusorderID,
|
RefundID: call.CusorderID,
|
||||||
// }
|
}
|
||||||
// db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
// if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
||||||
// if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
// orderPayRefund.Status = model.RefundStatusYes
|
orderPayRefund.Status = model.RefundStatusYes
|
||||||
// } else {
|
} else {
|
||||||
// orderPayRefund.Status = model.RefundStatusFailed
|
orderPayRefund.Status = model.RefundStatusFailed
|
||||||
// }
|
}
|
||||||
// orderPayRefund.OriginalData = utils.Format4Output(call, true)
|
orderPayRefund.OriginalData = utils.Format4Output(call, true)
|
||||||
// dao.UpdateEntity(db, orderPayRefund)
|
dao.UpdateEntity(db, orderPayRefund)
|
||||||
// } else if dao.IsNoRowsError(err) {
|
} else if dao.IsNoRowsError(err) {
|
||||||
// globals.SugarLogger.Warnf("收到异常的退款事件, call:%s", utils.Format4Output(call, true))
|
globals.SugarLogger.Warnf("收到异常的退款事件, call:%s", utils.Format4Output(call, true))
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
orderPay := &model.Order{
|
||||||
|
OrderID: orderPayRefund.VendorOrderID,
|
||||||
|
}
|
||||||
|
if err = dao.GetEntity(db, orderPay, "VendorOrderID"); err == nil {
|
||||||
|
orderPay.Status = model.OrderStatusCancel
|
||||||
|
}
|
||||||
|
if orderPay.OrderType == model.PayType4Express {
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if _, err = dao.UpdateEntityTx(tx, orderPay); err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err = dao.UpdateEntityTx(tx, &model.UserVendorOrder{LocalWayBill: call.CusorderID, OrderStatus: model.OrderStatusCancel}, "OrderStatus"); err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tx.Commit()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// orderPay := &model.OrderPay{
|
|
||||||
// VendorOrderID: orderPayRefund.VendorOrderID,
|
|
||||||
// VendorID: jxutils.GetPossibleVendorIDFromVendorOrderID(orderPayRefund.VendorOrderID),
|
|
||||||
// PayType: model.PayTypeWX,
|
|
||||||
// Status: model.PayStatusYes,
|
|
||||||
// }
|
|
||||||
// orderPay.DeletedAt = utils.DefaultTimeValue
|
|
||||||
// if err = dao.GetEntity(db, orderPay, "VendorOrderID", "VendorID", "PayType", "Status", "DeletedAt"); err == nil {
|
|
||||||
// orderPay.Status = model.PayStatusRefund
|
|
||||||
// dao.UpdateEntity(db, orderPay)
|
|
||||||
// }
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
|
||||||
// result, err := api.TLpayAPI.PayRefund(&tonglianpayapi.PayRefundParam{
|
|
||||||
// Trxamt: refundFee,
|
|
||||||
// Reqsn: utils.GetUUID(),
|
|
||||||
// Remark: refundDesc,
|
|
||||||
// OldTrxID: orderPay.TransactionID,
|
|
||||||
// })
|
|
||||||
// if err == nil {
|
|
||||||
// orderPayRefund = &model.OrderPayRefund{
|
|
||||||
// RefundID: refundID,
|
|
||||||
// VendorRefundID: result.TrxID,
|
|
||||||
// VendorOrderID: orderPay.VendorOrderID,
|
|
||||||
// VendorID: orderPay.VendorID,
|
|
||||||
// Status: model.RefundStatusNo,
|
|
||||||
// TransactionID: orderPay.TransactionID,
|
|
||||||
// RefundFee: refundFee,
|
|
||||||
// RefundCreatedAt: time.Now(),
|
|
||||||
// }
|
|
||||||
// dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
|
||||||
// db := dao.GetDB()
|
|
||||||
// if result.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
|
||||||
// orderPayRefund.Status = model.RefundStatusYes
|
|
||||||
// } else {
|
|
||||||
// orderPayRefund.Status = model.RefundStatusFailed
|
|
||||||
// }
|
|
||||||
// orderPayRefund.OriginalData = utils.Format4Output(result, true)
|
|
||||||
// dao.CreateEntity(db, orderPayRefund)
|
|
||||||
|
|
||||||
// orderPay.Status = model.PayStatusRefund
|
|
||||||
// dao.UpdateEntity(db, orderPay)
|
|
||||||
// }
|
|
||||||
// return orderPayRefund, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
func OnWxPayCallback(msg *wxpayapi.CallbackMsg) (err error) {
|
func OnWxPayCallback(msg *wxpayapi.CallbackMsg) (err error) {
|
||||||
globals.SugarLogger.Debugf("OnWxPayCallback msg:%s", utils.Format4Output(msg, true))
|
globals.SugarLogger.Debugf("OnWxPayCallback msg:%s", utils.Format4Output(msg, true))
|
||||||
switch msg.MsgType {
|
switch msg.MsgType {
|
||||||
|
|||||||
@@ -2,13 +2,15 @@ package financial
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/recharge_phone_bill"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/q_bida"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PayHandler struct {
|
type PayHandler struct {
|
||||||
@@ -36,9 +38,7 @@ type PayHandlerInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func OnPayFinished(order *model.Order) (err error) {
|
func OnPayFinished(order *model.Order) (err error) {
|
||||||
var (
|
var db = dao.GetDB()
|
||||||
db = dao.GetDB()
|
|
||||||
)
|
|
||||||
globals.SugarLogger.Debugf("OnPayFinished begin modify account order: %v", utils.Format4Output(order, false))
|
globals.SugarLogger.Debugf("OnPayFinished begin modify account order: %v", utils.Format4Output(order, false))
|
||||||
txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -104,3 +104,121 @@ func OnCashFinished(order *model.Order) (err error) {
|
|||||||
globals.SugarLogger.Debugf("OnCashFinished end modify account ...")
|
globals.SugarLogger.Debugf("OnCashFinished end modify account ...")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//微信支付充值会员
|
||||||
|
func OnWXPayFinished(order *model.Order) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
ctx *jxcontext.Context
|
||||||
|
txDB, _ = dao.Begin(db)
|
||||||
|
)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
//判断是新会员充值还是老会员续费
|
||||||
|
userMembers, err := dao.GetUserMember(db, order.UserID, model.MemberTypeNormal)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//根据订单类型来操作账户
|
||||||
|
if order.Type == model.OrderTypePay {
|
||||||
|
//为新会员生成会员信息并充值
|
||||||
|
if len(userMembers) > 0 {
|
||||||
|
if _, err := WXInvestMember(ctx, order.OrderType, order.UserID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := WXInvestMemberNew(ctx, order.OrderType, order.UserID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
order.Status = model.OrderStatusFinished
|
||||||
|
//更新order状态
|
||||||
|
if _, err := dao.UpdateEntityTx(txDB, &order, "Status"); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("暂不支持此订单类型!")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnWxPayTelephone 微信充值话费
|
||||||
|
func OnWxPayTelephone(order *model.Order) error {
|
||||||
|
orderNumber, err := api.TelephoneAPI.RechargePhoneBill(&recharge_phone_bill.RechargePhoneBillBase{
|
||||||
|
FlowCode: order.FlowCode,
|
||||||
|
Mobile: order.Mobile,
|
||||||
|
OrderNumber: order.OrderID,
|
||||||
|
CallbackURL: "http://callback.rsm.jxc4.com/recharge/msg",
|
||||||
|
ChargeType: "1",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
order.Comment = err.Error()
|
||||||
|
order.RechargeStatus = -1 // 充值失败
|
||||||
|
}
|
||||||
|
order.RechargeStatus = 1 // 充值中
|
||||||
|
order.Comment = orderNumber
|
||||||
|
//更新order状态
|
||||||
|
order.Status = model.OrderStatusFinished
|
||||||
|
if _, err := dao.UpdateEntity(dao.GetDB(), &order, "Status", "RechargeStatus", "Comment"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnWxPaySendPage 发快递支付方
|
||||||
|
func OnWxPaySendPage(db *dao.DaoDB, order *model.Order, call *tonglianpayapi.CallBackResult, payStatus int) (err error) {
|
||||||
|
txdb, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
order.TransactionID = call.TrxID
|
||||||
|
order.Status = 110 //支付成功状态
|
||||||
|
if _, err := dao.UpdateEntityTx(txdb, order, "TransactionID", "Status"); err != nil {
|
||||||
|
dao.Rollback(db, txdb)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userOrder := model.UserVendorOrder{LocalWayBill: order.OrderID}
|
||||||
|
if err := dao.GetEntity(db, &userOrder, "LocalWayBill"); err != nil {
|
||||||
|
dao.Rollback(db, txdb)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userOrder.OrderStatus = payStatus
|
||||||
|
if _, err := dao.UpdateEntityTx(txdb, &userOrder, "OrderStatus"); err != nil {
|
||||||
|
dao.Rollback(db, txdb)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//1-余额,2-微信,5-混合
|
||||||
|
if order.PayMethod == model.OrderPayMethodMix {
|
||||||
|
userBill, err := dao.GetUserBill(db, order.UserID, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//创建混合支付账单
|
||||||
|
totalPrice := order.PayPrice + userBill.AccountBalance
|
||||||
|
if err := AddMixPay(txdb, order.OrderID, userBill.AccountBalance, totalPrice, 1); err != nil {
|
||||||
|
dao.Rollback(db, txdb)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//余额清空
|
||||||
|
if err := dao.UpdateUserBill(order.UserID, 0); err != nil {
|
||||||
|
dao.Rollback(db, txdb)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dao.Commit(db, txdb)
|
||||||
|
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
|
switch order.OrderType {
|
||||||
|
case model.PayType4Express:
|
||||||
|
err = q_bida.CreateOrder2QBiDa(&userOrder, order.OrderID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package misc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd"
|
"git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
bidaServer "git.rosy.net.cn/jx-callback/business/q_bida"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
@@ -16,15 +18,18 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
dailyWorkTimeList = []string{
|
dailyWorkTimeList = []string{
|
||||||
"00:00:30",
|
"00:18:35",
|
||||||
}
|
}
|
||||||
stationTimeList = []string{
|
stationTimeList = []string{
|
||||||
"11:35:00",
|
"11:35:00",
|
||||||
}
|
}
|
||||||
|
startDeleteTime = []string{
|
||||||
|
"04:00:00",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
if globals.IsProductEnv() {
|
if globals.IsMainProductEnv() {
|
||||||
|
|
||||||
//拼多多订单轮询
|
//拼多多订单轮询
|
||||||
ScheduleTimerFuncByInterval(func() {
|
ScheduleTimerFuncByInterval(func() {
|
||||||
@@ -37,6 +42,16 @@ func Init() {
|
|||||||
//同步油站信息
|
//同步油站信息
|
||||||
cms.InitStation(jxcontext.AdminCtx)
|
cms.InitStation(jxcontext.AdminCtx)
|
||||||
}, stationTimeList)
|
}, stationTimeList)
|
||||||
|
|
||||||
|
// 定时删除打印信息
|
||||||
|
ScheduleTimerFunc("DeleteTimeOutPrintMsg", func() {
|
||||||
|
dao.DeletePrintMsg()
|
||||||
|
}, stationTimeList)
|
||||||
|
|
||||||
|
// 每两小时更新一下订单信息UpdateOrderStatus
|
||||||
|
ScheduleTimerFuncByInterval(func() {
|
||||||
|
bidaServer.UpdateOrderStatus()
|
||||||
|
}, 5*time.Second, 2*time.Hour)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +69,8 @@ func doDailyWork() {
|
|||||||
cms.RefreshDropShippingJob(jxcontext.AdminCtx)
|
cms.RefreshDropShippingJob(jxcontext.AdminCtx)
|
||||||
//刷新京东快递
|
//刷新京东快递
|
||||||
cms.RefreshJdDelivery(jxcontext.AdminCtx)
|
cms.RefreshJdDelivery(jxcontext.AdminCtx)
|
||||||
|
//美团联盟活动自动创建
|
||||||
|
cms.MtUnionJobAutoUpdate(jxcontext.AdminCtx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按时间序列循环
|
// 按时间序列循环
|
||||||
|
|||||||
@@ -25,3 +25,10 @@ func getAPI() (apiobj *mtunionapi.API) {
|
|||||||
}
|
}
|
||||||
return api.MtUnionAPI
|
return api.MtUnionAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAPI() (apiobj *mtunionapi.API) {
|
||||||
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "mtunionCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||||
|
api.MtUnionAPI.SetCookieWithStr(configs[0].Value)
|
||||||
|
}
|
||||||
|
return api.MtUnionAPI
|
||||||
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (act
|
|||||||
Ratio: v.Ratio,
|
Ratio: v.Ratio,
|
||||||
ActSrc: v.ActSrc,
|
ActSrc: v.ActSrc,
|
||||||
Img: v.URL,
|
Img: v.URL,
|
||||||
|
ActRule: v.ActRule,
|
||||||
}
|
}
|
||||||
if v.DateBound != "" {
|
if v.DateBound != "" {
|
||||||
act.DateBegin = utils.Str2Time(v.DateBound[:strings.LastIndex(v.DateBound, "至")-1])
|
act.DateBegin = utils.Str2Time(v.DateBound[:strings.LastIndex(v.DateBound, "至")-1])
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ type ActivityList struct {
|
|||||||
DateEnd time.Time `json:"dateEnd"`
|
DateEnd time.Time `json:"dateEnd"`
|
||||||
ActSrc string `json:"actSrc"` //物料?
|
ActSrc string `json:"actSrc"` //物料?
|
||||||
Img string `json:"img"` //活动图
|
Img string `json:"img"` //活动图
|
||||||
|
ActRule string `json:"actRule"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoodsDetail struct {
|
type GoodsDetail struct {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func ListConfig(key string) (configList []*legacymodel.Config, err error) {
|
|||||||
`
|
`
|
||||||
sqlParams := []interface{}{}
|
sqlParams := []interface{}{}
|
||||||
if key != "" {
|
if key != "" {
|
||||||
sql += " WHERE thirdparty = ?"
|
sql += " WHERE thirdparty = ?"
|
||||||
sqlParams = append(sqlParams, key)
|
sqlParams = append(sqlParams, key)
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package datares
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"github.com/qiniu/api.v7/storage"
|
||||||
"image"
|
"image"
|
||||||
"image/gif"
|
"image/gif"
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
@@ -15,8 +17,8 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
//"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
"github.com/qiniu/api.v7/storage"
|
//"github.com/qiniu/api.v7/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -108,10 +110,10 @@ func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, h
|
|||||||
return dataRes, err
|
return dataRes, err
|
||||||
}
|
}
|
||||||
if imgType > 0 {
|
if imgType > 0 {
|
||||||
if globals.EnableStoreWrite {
|
//if globals.EnableStoreWrite {
|
||||||
// 忽略上传错误
|
// 忽略上传错误
|
||||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
return dataRes, err
|
return dataRes, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,25 @@
|
|||||||
package datares
|
package datares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||||
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
testinit.Init()
|
testinit.Init()
|
||||||
api2.Init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetQiniuUploadToken(t *testing.T) {
|
//func TestGetQiniuUploadToken(t *testing.T) {
|
||||||
token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
|
// token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
fmt.Print(token)
|
// fmt.Print(token)
|
||||||
}
|
//}
|
||||||
|
|
||||||
func TestGetDataResource(t *testing.T) {
|
func TestGetDataResource(t *testing.T) {
|
||||||
dataRes, err := GetDataResource(jxcontext.AdminCtx, "1D3E4A8259F359FB4CF47D541843950D")
|
dataRes, err := GetDataResource(jxcontext.AdminCtx, "1D3E4A8259F359FB4CF47D541843950D")
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ func (h *Hub) GetToken(tokenType, oldToken string, waitTime time.Duration) (toke
|
|||||||
token = string(utils.MustMarshal(weimobToken))
|
token = string(utils.MustMarshal(weimobToken))
|
||||||
}
|
}
|
||||||
case EventTypePushToken:
|
case EventTypePushToken:
|
||||||
token = api.PushAPI.CBGetToken()
|
//token = api.PushAPI.CBGetToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
if token != oldToken {
|
if token != oldToken {
|
||||||
|
|||||||
@@ -7,10 +7,13 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"golang.org/x/text/encoding/simplifiedchinese"
|
||||||
|
"golang.org/x/text/transform"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -830,7 +833,7 @@ func MixWatermarkImg(imgWatermark, img, positon string) (imgMix string) {
|
|||||||
imgUrl = img + "?imageView2/0/q/75|watermark/1/image/" + baseURL + "/dissolve/100/gravity/" + positon + "/dx/10/dy/10"
|
imgUrl = img + "?imageView2/0/q/75|watermark/1/image/" + baseURL + "/dissolve/100/gravity/" + positon + "/dx/10/dy/10"
|
||||||
}
|
}
|
||||||
if resBinary, _, err := DownloadFileByURL(imgUrl); err == nil {
|
if resBinary, _, err := DownloadFileByURL(imgUrl); err == nil {
|
||||||
if downloadURL, err := UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+img[strings.LastIndex(img, "/")+1:len(img)]); err == nil {
|
if downloadURL, err := UploadExportContent(resBinary, "image/"+utils.Int64ToStr(time.Now().Unix())+img[strings.LastIndex(img, "/")+1:len(img)]); err == nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return downloadURL
|
return downloadURL
|
||||||
}
|
}
|
||||||
@@ -900,3 +903,27 @@ func GetWeekTime() (weekTimeBegin, weekTimeEnd time.Time) {
|
|||||||
weekTimeEnd = weekTimeBegin.AddDate(0, 0, 7)
|
weekTimeEnd = weekTimeBegin.AddDate(0, 0, 7)
|
||||||
return weekTimeBegin, weekTimeEnd
|
return weekTimeBegin, weekTimeEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Utf8ToGbk(str []byte) (b []byte, err error) {
|
||||||
|
r := transform.NewReader(bytes.NewReader(str), simplifiedchinese.GBK.NewEncoder())
|
||||||
|
b, err = ioutil.ReadAll(r)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func Hextob(str string) []byte {
|
||||||
|
slen := len(str)
|
||||||
|
bHex := make([]byte, len(str)/2)
|
||||||
|
ii := 0
|
||||||
|
for i := 0; i < len(str); i = i + 2 {
|
||||||
|
if slen != 1 {
|
||||||
|
ss := string(str[i]) + string(str[i+1])
|
||||||
|
bt, _ := strconv.ParseInt(ss, 16, 32)
|
||||||
|
bHex[ii] = byte(bt)
|
||||||
|
ii = ii + 1
|
||||||
|
slen = slen - 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bHex
|
||||||
|
}
|
||||||
|
|||||||
@@ -461,3 +461,11 @@ func CalcPolygonAreaAutonavi(points [][2]float64) (area float64) {
|
|||||||
d += eee*point[1]*c - k*g2
|
d += eee*point[1]*c - k*g2
|
||||||
return 0.5 * math.Abs(d) / float64(1000000)
|
return 0.5 * math.Abs(d) / float64(1000000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BuildErr(errs []error) (err error) {
|
||||||
|
var errStr = strings.Builder{}
|
||||||
|
for _, v := range errs {
|
||||||
|
errStr.WriteString(v.Error())
|
||||||
|
}
|
||||||
|
return fmt.Errorf(errStr.String())
|
||||||
|
}
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ func TestSplitUniversalOrderID(t *testing.T) {
|
|||||||
[]interface{}{
|
[]interface{}{
|
||||||
"3022716176275221584",
|
"3022716176275221584",
|
||||||
"3022716176275221584",
|
"3022716176275221584",
|
||||||
model.VendorIDELM,
|
|
||||||
},
|
},
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
"15380342248732",
|
"15380342248732",
|
||||||
@@ -105,7 +104,6 @@ func TestSplitUniversalOrderID(t *testing.T) {
|
|||||||
[]interface{}{
|
[]interface{}{
|
||||||
"5287873015048",
|
"5287873015048",
|
||||||
"5287873015048",
|
"5287873015048",
|
||||||
model.VendorIDWSC,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, v := range testData {
|
for _, v := range testData {
|
||||||
@@ -151,7 +149,6 @@ func TestGetPossibleVendorIDFromVendorOrderID(t *testing.T) {
|
|||||||
},
|
},
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
"5287873015048",
|
"5287873015048",
|
||||||
model.VendorIDWSC,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, v := range testData {
|
for _, v := range testData {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||||
@@ -33,7 +32,7 @@ func SendUserMessage(msgType string, user *model.User, title, content string) (e
|
|||||||
}
|
}
|
||||||
err = ddmsg.SendDDUserMessage(msgType, auth.AuthID, title, content)
|
err = ddmsg.SendDDUserMessage(msgType, auth.AuthID, title, content)
|
||||||
} else if auth.Type == weixin.AuthTypeMP && msgType != dingdingapi.MsgTypeMarkdown {
|
} else if auth.Type == weixin.AuthTypeMP && msgType != dingdingapi.MsgTypeMarkdown {
|
||||||
err = weixinmsg.NotifyStoreStatusChanged(auth.AuthID, title, content)
|
//err = weixinmsg.NotifyStoreStatusChanged(auth.AuthID, title, content)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func SendSMSMsg(mobileList []string, signName, templateCode string, templatePara
|
|||||||
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
||||||
for _, mobileNum := range mobileList {
|
for _, mobileNum := range mobileList {
|
||||||
if mobileNum != "" {
|
if mobileNum != "" {
|
||||||
globals.SugarLogger.Debugf("SendSMSMsg mobileNum:%s, templateCode:%s", mobileNum, templateCode)
|
globals.SugarLogger.Debugf("SendSMSMsg 1 mobileNum:%s, templateCode:%s", mobileNum, templateCode)
|
||||||
if true { //globals.EnableStoreWrite {
|
if true { //globals.EnableStoreWrite {
|
||||||
if response, err := api.SMSClient.Execute(globals.AliKey, globals.AliSecret, mobileNum, signName, templateCode, string(utils.MustMarshal(templateParam))); err != nil {
|
if response, err := api.SMSClient.Execute(globals.AliKey, globals.AliSecret, mobileNum, signName, templateCode, string(utils.MustMarshal(templateParam))); err != nil {
|
||||||
globals.SugarLogger.Warnf("SendSMSMsg mobileNum:%s failed with error:%v", mobileNum, err)
|
globals.SugarLogger.Warnf("SendSMSMsg mobileNum:%s failed with error:%v", mobileNum, err)
|
||||||
|
|||||||
@@ -138,60 +138,6 @@ func RefreshWeixinToken() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshPushToken() (err error) {
|
|
||||||
if api.PushAPI != nil {
|
|
||||||
err = RefreshConfig("push", pushTokenExpires, func() (token string, expireTimeStr string) {
|
|
||||||
globals.SugarLogger.Debugf("RefreshPushToken RunMode:%s", beego.BConfig.RunMode)
|
|
||||||
if globals.IsMainProductEnv() {
|
|
||||||
if tokenInfo, err := api.PushAPI.CBRetrieveToken(); err == nil {
|
|
||||||
globals.SugarLogger.Debugf("RefreshPushToken tokenInfo:%s", utils.Format4Output(tokenInfo, true))
|
|
||||||
token = tokenInfo.Token
|
|
||||||
} else {
|
|
||||||
globals.SugarLogger.Errorf("RefreshPushToken RefreshToken failed with error:%v", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if tokenInfo := getPushTokenFromRemote(api.PushAPI.CBGetToken()); tokenInfo != nil {
|
|
||||||
expireTimeStr = utils.Time2Str(time.Now().Add(-pushTokenExpires))
|
|
||||||
token = tokenInfo.Token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return token, expireTimeStr
|
|
||||||
}, func(value string) {
|
|
||||||
globals.SugarLogger.Debugf("RefreshPushToken setter value:%s", value)
|
|
||||||
syseventhub.SysEventHub.OnNewPushToken(value)
|
|
||||||
api.PushAPI.CBSetToken(value)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func RefreshWeixin3Token() (err error) {
|
|
||||||
// if api.WeixinMiniAPI3 != nil {
|
|
||||||
// err = RefreshConfig("wechat3", weixinTokenExpires, func() (token string, expireTimeStr string) {
|
|
||||||
// globals.SugarLogger.Debugf("RefreshWeixin3Token RunMode:%s", beego.BConfig.RunMode)
|
|
||||||
// if globals.IsMainProductEnv() {
|
|
||||||
// if tokenInfo, err := api.WeixinMiniAPI3.CBRetrieveToken(); err == nil {
|
|
||||||
// globals.SugarLogger.Debugf("RefreshWeixin3Token tokenInfo:%s", utils.Format4Output(tokenInfo, true))
|
|
||||||
// token = tokenInfo.AccessToken
|
|
||||||
// } else {
|
|
||||||
// globals.SugarLogger.Errorf("RefreshWeixin3Token RefreshToken failed with error:%v", err)
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if tokenInfo := getWX3TokenFromRemote(api.WeixinMiniAPI3.CBGetToken()); tokenInfo != nil {
|
|
||||||
// expireTimeStr = utils.Time2Str(time.Now().Add(-weixinTokenExpires))
|
|
||||||
// token = tokenInfo.Token
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return token, expireTimeStr
|
|
||||||
// }, func(value string) {
|
|
||||||
// globals.SugarLogger.Debugf("RefreshWeixinToken setter value:%s", value)
|
|
||||||
// syseventhub.SysEventHub.OnNewWX3Token(value)
|
|
||||||
// api.WeixinMiniAPI3.CBSetToken(value)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func RefreshWeimobToken() (err error) {
|
func RefreshWeimobToken() (err error) {
|
||||||
if api.WeimobAPI != nil {
|
if api.WeimobAPI != nil {
|
||||||
err = RefreshConfig("weimob", weimobTokenExpires, func() (token string, expireTimeStr string) {
|
err = RefreshConfig("weimob", weimobTokenExpires, func() (token string, expireTimeStr string) {
|
||||||
|
|||||||
@@ -476,7 +476,9 @@ func (t *BaseTask) run(taskHandler func()) {
|
|||||||
if t.finishHook != nil {
|
if t.finishHook != nil {
|
||||||
t.finishHook(t)
|
t.finishHook(t)
|
||||||
} else {
|
} else {
|
||||||
SendMessage(t)
|
if globals.IsMainProductEnv() {
|
||||||
|
SendMessage(t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,95 +1,82 @@
|
|||||||
package push
|
package push
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/unipushapi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
"github.com/astaxie/beego"
|
|
||||||
)
|
|
||||||
|
|
||||||
func pushToSingle(content, title string, storeID int) {
|
func pushToSingle(content, title string, storeID int) {
|
||||||
var (
|
//var (
|
||||||
db = dao.GetDB()
|
// db = dao.GetDB()
|
||||||
)
|
//)
|
||||||
if !globals.IsProductEnv() {
|
//if !globals.IsProductEnv() {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
storePushs, err := dao.GetStorePushClient(db, storeID, "")
|
//storePushs, err := dao.GetStorePushClient(db, storeID, "")
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
for _, v := range storePushs {
|
//for _, v := range storePushs {
|
||||||
|
//
|
||||||
status, err2 := api.PushAPI.PushToSingle(v.ClientID, false, &unipushapi.Notification{
|
// status, err2 := api.PushAPI.PushToSingle(v.ClientID, false, &unipushapi.Notification{
|
||||||
Title: title,
|
// Title: title,
|
||||||
Body: content,
|
// Body: content,
|
||||||
})
|
// })
|
||||||
if err = err2; err != nil {
|
// if err = err2; err != nil {
|
||||||
globals.SugarLogger.Debugf("NotifyNewOrder push error: [%v]", err)
|
// globals.SugarLogger.Debugf("NotifyNewOrder push error: [%v]", err)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if status == unipushapi.SuccessOffLine {
|
// if status == unipushapi.SuccessOffLine {
|
||||||
_, err = api.PushAPI.PushToSingle(v.ClientID, true, &unipushapi.Notification{
|
// _, err = api.PushAPI.PushToSingle(v.ClientID, true, &unipushapi.Notification{
|
||||||
Body: content,
|
// Body: content,
|
||||||
})
|
// })
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
globals.SugarLogger.Debugf("NotifyNewOrder push2 error: [%v]", err)
|
// globals.SugarLogger.Debugf("NotifyNewOrder push2 error: [%v]", err)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotifyNewOrder(order *model.GoodsOrder) {
|
//
|
||||||
globals.SugarLogger.Debugf("NotifyNewOrder push begin orderID :[%v]", order.VendorOrderID)
|
//func NotifyNewOrder(order *model.GoodsOrder) {
|
||||||
sb := new(strings.Builder)
|
// globals.SugarLogger.Debugf("NotifyNewOrder push begin orderID :[%v]", order.VendorOrderID)
|
||||||
sb.WriteString("老板,")
|
// sb := new(strings.Builder)
|
||||||
sb.WriteString(order.ConsigneeName)
|
// sb.WriteString("老板,")
|
||||||
sb.WriteString("购买了商品")
|
// sb.WriteString(order.ConsigneeName)
|
||||||
sb.WriteString(getOrderDetailBrief(order))
|
// sb.WriteString("购买了商品")
|
||||||
pushToSingle(sb.String(), "京西菜市新订单推送", jxutils.GetSaleStoreIDFromOrder(order))
|
// sb.WriteString(getOrderDetailBrief(order))
|
||||||
}
|
// pushToSingle(sb.String(), "京西菜市新订单推送", jxutils.GetSaleStoreIDFromOrder(order))
|
||||||
|
//}
|
||||||
func getOrderDetailBrief(order *model.GoodsOrder) (brief string) {
|
//
|
||||||
sb := new(strings.Builder)
|
//func getOrderDetailBrief(order *model.GoodsOrder) (brief string) {
|
||||||
sb.WriteString(order.Skus[0].SkuName)
|
// sb := new(strings.Builder)
|
||||||
sb.WriteString("等共")
|
// sb.WriteString(order.Skus[0].SkuName)
|
||||||
sb.WriteString(utils.Int2Str(order.Skus[0].Count))
|
// sb.WriteString("等共")
|
||||||
sb.WriteString("份(")
|
// sb.WriteString(utils.Int2Str(order.Skus[0].Count))
|
||||||
sb.WriteString(jxutils.IntPrice2StandardString(order.Skus[0].SalePrice))
|
// sb.WriteString("份(")
|
||||||
sb.WriteString("元/份)等,预计收入")
|
// sb.WriteString(jxutils.IntPrice2StandardString(order.Skus[0].SalePrice))
|
||||||
//TODO 2020-07-20 果园和菜市不同
|
// sb.WriteString("元/份)等,预计收入")
|
||||||
var price int64
|
// //TODO 2020-07-20 果园和菜市不同
|
||||||
if beego.BConfig.RunMode == "jxgy" {
|
// var price int64
|
||||||
price = order.EarningPrice
|
// if beego.BConfig.RunMode == "jxgy" {
|
||||||
} else {
|
// price = order.EarningPrice
|
||||||
if order.EarningType == model.EarningTypePoints {
|
// } else {
|
||||||
price = order.ActualPayPrice
|
// if order.EarningType == model.EarningTypePoints {
|
||||||
} else {
|
// price = order.ActualPayPrice
|
||||||
price = order.ShopPrice
|
// } else {
|
||||||
}
|
// price = order.ShopPrice
|
||||||
}
|
// }
|
||||||
sb.WriteString(jxutils.IntPrice2StandardString(price))
|
// }
|
||||||
sb.WriteString("元")
|
// sb.WriteString(jxutils.IntPrice2StandardString(price))
|
||||||
return sb.String()
|
// sb.WriteString("元")
|
||||||
}
|
// return sb.String()
|
||||||
|
//}
|
||||||
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
//
|
||||||
globals.SugarLogger.Debugf("NotifyAfsOrder push begin orderID :[%v]", afsOrder.VendorOrderID)
|
//func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
||||||
pushToSingle("老板,您有新的售后单,请尽快处理!", "京西菜市售后单推送", jxutils.GetSaleStoreIDFromAfsOrder(afsOrder))
|
// globals.SugarLogger.Debugf("NotifyAfsOrder push begin orderID :[%v]", afsOrder.VendorOrderID)
|
||||||
return err
|
// pushToSingle("老板,您有新的售后单,请尽快处理!", "京西菜市售后单推送", jxutils.GetSaleStoreIDFromAfsOrder(afsOrder))
|
||||||
}
|
// return err
|
||||||
|
//}
|
||||||
func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
//
|
||||||
title := fmt.Sprintf("老板,您的订单%s第%d号订单, %s被取消了!", model.VendorChineseNames[order.VendorID], order.OrderSeq, order.VendorOrderID)
|
//func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
||||||
pushToSingle(title, "京西菜市取消单推送", jxutils.GetSaleStoreIDFromOrder(order))
|
// title := fmt.Sprintf("老板,您的订单%s第%d号订单, %s被取消了!", model.VendorChineseNames[order.VendorID], order.OrderSeq, order.VendorOrderID)
|
||||||
return err
|
// pushToSingle(title, "京西菜市取消单推送", jxutils.GetSaleStoreIDFromOrder(order))
|
||||||
}
|
// return err
|
||||||
|
//}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ var (
|
|||||||
VendorColors = map[int]string{
|
VendorColors = map[int]string{
|
||||||
model.VendorIDJD: WX_TEMPLATE_VENDERCOLOR_JDDJ,
|
model.VendorIDJD: WX_TEMPLATE_VENDERCOLOR_JDDJ,
|
||||||
model.VendorIDMTWM: WX_TEMPLATE_VENDERCOLOR_MT,
|
model.VendorIDMTWM: WX_TEMPLATE_VENDERCOLOR_MT,
|
||||||
model.VendorIDELM: WX_TEMPLATE_VENDERCOLOR_ELM,
|
//model.VendorIDELM: WX_TEMPLATE_VENDERCOLOR_ELM,
|
||||||
model.VendorIDEBAI: WX_TEMPLATE_VENDERCOLOR_ELM,
|
model.VendorIDEBAI: WX_TEMPLATE_VENDERCOLOR_ELM,
|
||||||
}
|
}
|
||||||
testMiniProgramStoreMap = map[int]int{
|
testMiniProgramStoreMap = map[int]int{
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ const (
|
|||||||
VendorIDMTWM = 1
|
VendorIDMTWM = 1
|
||||||
VendorIDPDD = 2 //拼多多
|
VendorIDPDD = 2 //拼多多
|
||||||
VendorIDEBAI = 3
|
VendorIDEBAI = 3
|
||||||
VendorIDTB = 4 //淘宝
|
VendorIDTT = 14
|
||||||
VendorIDJDShop = 5 //京东商城
|
VendorIDTB = 16 //淘宝
|
||||||
VendorIDJX = 9 // 这是一个假的京西VendorID
|
VendorIDJDShop = 5 //京东商城
|
||||||
|
VendorIDJX = 9 // 这是一个假的京西VendorID
|
||||||
VendorIDPurchaseEnd = 10
|
VendorIDPurchaseEnd = 10
|
||||||
VendorIDOther = 999 //其他平台
|
VendorIDOther = 999 //其他平台
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ const (
|
|||||||
BillTypeDropShippingDeposit = 18 //一件代发保证金
|
BillTypeDropShippingDeposit = 18 //一件代发保证金
|
||||||
BillTypeUnionShare = 19 //联盟任务分成
|
BillTypeUnionShare = 19 //联盟任务分成
|
||||||
|
|
||||||
BillTypeMember = 20 //开通会员
|
BillTypeMember = 20 //开通会员
|
||||||
|
BillTypePayByAccountBalance = 25 //余额支付
|
||||||
BillTypeQuitGroup = 30 //退群
|
BillTypePayByMixPay1 = 26 //混合支付中的 余额部分状态码
|
||||||
|
BillTypePayByMixPay2 = 27 //混合支付中的 微信部分状态码
|
||||||
|
BillMixPayRefund1 = 28 //混合支付 余额部分退款
|
||||||
|
BillTypeQuitGroup = 30 //退群
|
||||||
|
|
||||||
BillTypeJdWaybillOverWeight = 40 //京东物流超重扣款
|
BillTypeJdWaybillOverWeight = 40 //京东物流超重扣款
|
||||||
|
|
||||||
@@ -41,6 +44,24 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//混合支付详情表
|
||||||
|
type MixPay struct {
|
||||||
|
ModelIDCUL
|
||||||
|
|
||||||
|
OrderID string `orm:"column(order_id)" json:"order_id"` //账单ID 对应order表
|
||||||
|
BalancePrice int `orm:"column(balance_price)" json:"balance_price"` //余额支付部分
|
||||||
|
TotalPrice int `orm:"column(total_price)" json:"total_price"` //订单总额
|
||||||
|
WxPrice int `orm:"column(wx_price)" json:"wx_price"` //微信支付部分
|
||||||
|
Status int `orm:"column(status)" json:"status"` //订单状态 -1:退款/1:正常
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *MixPay) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"OrderID"},
|
||||||
|
[]string{"CreatedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//账单收入表
|
//账单收入表
|
||||||
type BillIncome struct {
|
type BillIncome struct {
|
||||||
ModelIDCUL
|
ModelIDCUL
|
||||||
@@ -79,9 +100,9 @@ func (v *BillExpend) TableIndex() [][]string {
|
|||||||
type UserBill struct {
|
type UserBill struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
|
||||||
BillID int64 `orm:"column(bill_id)" json:"billID"` //账单ID
|
BillID int64 `orm:"column(bill_id)" json:"billID"` //账单ID
|
||||||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID
|
UserID string `orm:"column(user_id)" json:"userID"` //用户ID
|
||||||
AccountBalance int `json:"accountBalance"` //账户余额
|
AccountBalance int `orm:"column(account_balance)" json:"accountBalance"` //账户余额
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *UserBill) TableUnique() [][]string {
|
func (v *UserBill) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ var (
|
|||||||
WaybillStatusDelivered: "送达",
|
WaybillStatusDelivered: "送达",
|
||||||
WaybillStatusCanceled: "取消",
|
WaybillStatusCanceled: "取消",
|
||||||
WaybillStatusFailed: "失败",
|
WaybillStatusFailed: "失败",
|
||||||
|
WaybillStatusCourierAssigned: "已分配骑手",
|
||||||
}
|
}
|
||||||
OrderTypeName = map[int]string{
|
OrderTypeName = map[int]string{
|
||||||
OrderTypeOrder: "订单",
|
OrderTypeOrder: "订单",
|
||||||
@@ -276,6 +277,17 @@ const (
|
|||||||
AfsOrderStatusReceivedGoods = 167 // 已确认收到货
|
AfsOrderStatusReceivedGoods = 167 // 已确认收到货
|
||||||
AfsOrderStatusFinished = 180 // 售后单成功完成
|
AfsOrderStatusFinished = 180 // 售后单成功完成
|
||||||
AfsOrderStatusFailed = 190 // 售后单失败
|
AfsOrderStatusFailed = 190 // 售后单失败
|
||||||
|
|
||||||
|
ApplyOrderRefund = 130 // 申请退款
|
||||||
|
OrderStatusRejection = 132 // 客户拒收
|
||||||
|
OrderStatusCustomerService = 131 // 客服退款
|
||||||
|
ApplyOrderCancel = 140 // 申请取消
|
||||||
|
ApplyOrderRefundGoods = 150 // 申请退款
|
||||||
|
UserInStoreConsultingService = 160 // 进店咨询
|
||||||
|
BusinessCancelOrder = 170 // 商家取消打印
|
||||||
|
CancelOrderSuccess = 170 // 取消成功打印
|
||||||
|
OrderRefundMoneySuccess = 180 // 退款成功打印
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//联盟订单状态
|
//联盟订单状态
|
||||||
@@ -335,6 +347,10 @@ const (
|
|||||||
WaybillStatusCanceled = 115
|
WaybillStatusCanceled = 115
|
||||||
WaybillStatusFailed = 120 // 这个状态存在的意义是区分于WaybillStatusCanceled,比如达达平台在这种状态下再次创建运单的方式不一样
|
WaybillStatusFailed = 120 // 这个状态存在的意义是区分于WaybillStatusCanceled,比如达达平台在这种状态下再次创建运单的方式不一样
|
||||||
WaybillStatusEndEnd = 120
|
WaybillStatusEndEnd = 120
|
||||||
|
|
||||||
|
WaybillStatusCourierAssigned = 12 //已分配骑手
|
||||||
|
WaybillStatusDeliverReminder = 30 // 催单
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -25,6 +26,11 @@ func GetUserBill(db *DaoDB, userID, billID string) (userBill *model.UserBill, er
|
|||||||
return userBill, err
|
return userBill, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加用户支出记录
|
||||||
|
func AddUserExpend() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func GetBillExpend(db *DaoDB, userID string, billType int, fromTime, toTime time.Time) (billExpends []*model.BillExpend, err error) {
|
func GetBillExpend(db *DaoDB, userID string, billType int, fromTime, toTime time.Time) (billExpends []*model.BillExpend, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT b.*
|
SELECT b.*
|
||||||
@@ -129,3 +135,48 @@ func GetUserBillDetail(db *DaoDB, userID string, fromTime, toTime time.Time, pag
|
|||||||
}
|
}
|
||||||
return pagedInfo, err
|
return pagedInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateUserBill 修改用户余额
|
||||||
|
func UpdateUserBill(userId string, money int) error {
|
||||||
|
_, err := ExecuteSQL(GetDB(), `UPDATE user_bill SET account_balance = ? WHERE user_id = ? `, []interface{}{money, userId}...)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type MixPayDetail struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdateAt time.Time `json:"update_at"`
|
||||||
|
LastOperator string `json:"lastOperator"`
|
||||||
|
OrderID string `json:"order_id"`
|
||||||
|
BalancePrice int `json:"balance_price"`
|
||||||
|
TotalPrice int `json:"total_price"`
|
||||||
|
WxPrice int `json:"wx_price"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取混合支付 余额部分信息
|
||||||
|
func GetMixPayDetail(orderID string) (details *model.MixPay, err error) {
|
||||||
|
//var info []*MixPayDetail
|
||||||
|
info := make([]*model.MixPay, 0)
|
||||||
|
var sqlParams []interface{}
|
||||||
|
sql := ""
|
||||||
|
if orderID != "" {
|
||||||
|
sql += "SELECT * FROM mix_pay WHERE order_id = ?"
|
||||||
|
sqlParams = append(sqlParams, orderID)
|
||||||
|
}
|
||||||
|
err = GetRows(GetDB(), &info, sql, sqlParams...)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debug("er===========", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return info[0], err
|
||||||
|
//if err == nil {
|
||||||
|
// details = &MixPayDetail{
|
||||||
|
// OrderID: info[0].OrderID,
|
||||||
|
// BalancePrice: info[0].BalancePrice,
|
||||||
|
// TotalPrice: info[0].TotalPrice,
|
||||||
|
// WxPrice: info[0].WxPrice,
|
||||||
|
// Status: info[0].Status,
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetJob(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (job *model.Job, err error) {
|
func GetJob(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (job *model.Job, err error) {
|
||||||
jobs, err := GetJobsNoPage(db, userIDs, categoryIDs, statuss, types, fromTime, toTime, 0, includeStep)
|
jobs, err := GetJobsNoPage(db, userIDs, nil, categoryIDs, statuss, types, fromTime, toTime, 0, includeStep)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return job, err
|
return job, err
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ func GetJobWithTitle(db *DaoDB, title string) (job *model.Job, err error) {
|
|||||||
return job, err
|
return job, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, span int, includeStep bool) (jobs []*GetJobsResult, err error) {
|
func GetJobsNoPage(db *DaoDB, userIDs []string, vendorIDs, categoryIDs, statuss, types []int, fromTime, toTime time.Time, span int, includeStep bool) (jobs []*GetJobsResult, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT a.*, b.name
|
SELECT a.*, b.name
|
||||||
FROM job a
|
FROM job a
|
||||||
@@ -195,6 +195,10 @@ func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []in
|
|||||||
sql += ` AND a.user_id IN (` + GenQuestionMarks(len(userIDs)) + `)`
|
sql += ` AND a.user_id IN (` + GenQuestionMarks(len(userIDs)) + `)`
|
||||||
sqlParams = append(sqlParams, userIDs)
|
sqlParams = append(sqlParams, userIDs)
|
||||||
}
|
}
|
||||||
|
if len(vendorIDs) > 0 {
|
||||||
|
sql += ` AND a.vendor_id IN (` + GenQuestionMarks(len(vendorIDs)) + `)`
|
||||||
|
sqlParams = append(sqlParams, vendorIDs)
|
||||||
|
}
|
||||||
if len(categoryIDs) > 0 {
|
if len(categoryIDs) > 0 {
|
||||||
sql += ` AND a.job_category_id IN (` + GenQuestionMarks(len(categoryIDs)) + `)`
|
sql += ` AND a.job_category_id IN (` + GenQuestionMarks(len(categoryIDs)) + `)`
|
||||||
sqlParams = append(sqlParams, categoryIDs)
|
sqlParams = append(sqlParams, categoryIDs)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/astaxie/beego/client/orm"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -124,6 +125,22 @@ type GetOrdersResult struct {
|
|||||||
Mobile string `json:"mobile"`
|
Mobile string `json:"mobile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var TableOrder = "order"
|
||||||
|
|
||||||
|
func GetOrderByID(db *DaoDB, orderID string) (*model.Order, error) {
|
||||||
|
sql := `SELECT * FROM` + "`order`" + ` WHERE 1 = 1 `
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if orderID != "" {
|
||||||
|
sql += `AND order_id = ?`
|
||||||
|
sqlParams = append(sqlParams, orderID)
|
||||||
|
}
|
||||||
|
orderInfos := &model.Order{}
|
||||||
|
if err := GetRow(db, orderInfos, sql, sqlParams); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return orderInfos, nil
|
||||||
|
}
|
||||||
|
|
||||||
func GetOrders(db *DaoDB, orderID, userID string, orderType int, cityCodes []int, fromTime, toTime time.Time, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
func GetOrders(db *DaoDB, orderID, userID string, orderType int, cityCodes []int, fromTime, toTime time.Time, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||||
var orders []*GetOrdersResult
|
var orders []*GetOrdersResult
|
||||||
sql := `
|
sql := `
|
||||||
@@ -652,3 +669,72 @@ func GetUnionOrdersPage(db *DaoDB, vendorIDs, statuss []int, beginTime, endTime
|
|||||||
}
|
}
|
||||||
return page, err
|
return page, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更新user_vendor_order 支付状态
|
||||||
|
func SetUserVendorOrderStatus(tx orm.TxOrmer, localWayBillID string, status int) (msg string, err error) {
|
||||||
|
if _, err := ExecuteSQL(GetDB(), "UPDATE `user_vendor_order` SET order_status = ? WHERE local_way_bill = ? ", []interface{}{status, localWayBillID}...); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return "更新UserVendorOrder状态成功", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryRechargeRecommend 电话充值记录查询
|
||||||
|
func QueryRechargeRecommend(userId []string, mobile, orderId string, page, pageSize int, start, end time.Time, rechargeStatus int) ([]*model.RechargeUserModelData, int, error) {
|
||||||
|
result := make([]*model.RechargeUserModelData, 0, 0)
|
||||||
|
sql := `SELECT SQL_CALC_FOUND_ROWS o.*,u.name FROM ` + "`order`" + ` o`
|
||||||
|
sqlParams := make([]interface{}, 0, 0)
|
||||||
|
|
||||||
|
sql += ` JOIN user u ON o.user_id = u.user_id WHERE 1=1 `
|
||||||
|
|
||||||
|
if orderId != "" {
|
||||||
|
sql += ` AND o.order_id = ? `
|
||||||
|
sqlParams = append(sqlParams, orderId)
|
||||||
|
if err := GetRows(GetDB(), &result, sql, sqlParams...); err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return result, 1, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if userId != nil && len(userId) > 0 {
|
||||||
|
sql += ` AND o.user_id IN (` + GenQuestionMarks(len(userId)) + `)`
|
||||||
|
sqlParams = append(sqlParams, userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !utils.IsTimeZero(start) {
|
||||||
|
sql += ` AND o.created_at > ? `
|
||||||
|
sqlParams = append(sqlParams, start)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(end) {
|
||||||
|
sql += ` AND o.created_at < ? `
|
||||||
|
sqlParams = append(sqlParams, end)
|
||||||
|
}
|
||||||
|
|
||||||
|
if mobile != "" {
|
||||||
|
sql += ` AND o.mobile = ? `
|
||||||
|
sqlParams = append(sqlParams, mobile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rechargeStatus != 0 {
|
||||||
|
sql += ` AND o.recharge_status = ? `
|
||||||
|
sqlParams = append(sqlParams, rechargeStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
sql += " ORDER BY o.created_at DESC LIMIT ? OFFSET ?"
|
||||||
|
sqlParams = append(sqlParams, jxutils.FormalizePageSize(pageSize), (page-1)*pageSize)
|
||||||
|
|
||||||
|
db := GetDB()
|
||||||
|
tx, _ := Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
Rollback(db, tx)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := GetRowsTx(tx, &result, sql, sqlParams...); err != nil {
|
||||||
|
Rollback(db, tx)
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
count := GetLastTotalRowCountTx(tx)
|
||||||
|
return result, count, nil
|
||||||
|
}
|
||||||
|
|||||||
162
business/model/dao/dao_print.go
Normal file
162
business/model/dao/dao_print.go
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPrintMsgNoPage(db *DaoDB, printNo string, orderNo int64) (prints []*model.PrintMsg, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM print_msg
|
||||||
|
WHERE 1 = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += ` AND print_no = ?`
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if orderNo != 0 {
|
||||||
|
sql += ` AND order_no = ?`
|
||||||
|
sqlParams = append(sqlParams, orderNo)
|
||||||
|
}
|
||||||
|
sql += " ORDER BY created_at DESC LIMIT 1"
|
||||||
|
err = GetRows(db, &prints, sql, sqlParams)
|
||||||
|
return prints, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrintMsgs(db *DaoDB, printNo string, statuss []int, beginAt, endAt time.Time, offset, pageSize int) (prints []*model.PrintMsg, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT a.*
|
||||||
|
FROM print_msg a
|
||||||
|
WHERE 1 = 1 AND a.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += " AND a.print_no = ?"
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if len(statuss) > 0 {
|
||||||
|
sql += " AND a.status IN(" + GenQuestionMarks(len(statuss)) + ")"
|
||||||
|
sqlParams = append(sqlParams, statuss)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(beginAt) {
|
||||||
|
sql += " AND a.created_at > ?"
|
||||||
|
sqlParams = append(sqlParams, beginAt)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(endAt) {
|
||||||
|
sql += " AND a.created_at < ?"
|
||||||
|
sqlParams = append(sqlParams, endAt)
|
||||||
|
}
|
||||||
|
sql += " ORDER BY a.created_at LIMIT ? OFFSET ?"
|
||||||
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
|
err = GetRows(db, &prints, sql, sqlParams)
|
||||||
|
return prints, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrintMsg2(db *DaoDB, printNo, msgID string, status, statusNeq int) (printMsgs []*model.PrintMsg, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM print_msg
|
||||||
|
WHERE 1 = 1 AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if status != model.PrintMsgAll {
|
||||||
|
sql += " AND status = ?"
|
||||||
|
sqlParams = append(sqlParams, status)
|
||||||
|
}
|
||||||
|
if statusNeq != model.PrintMsgAll {
|
||||||
|
sql += " AND status <> ?"
|
||||||
|
sqlParams = append(sqlParams, statusNeq)
|
||||||
|
}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += " AND print_no = ?"
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if msgID != "" {
|
||||||
|
sql += " AND msg_id = ?"
|
||||||
|
sqlParams = append(sqlParams, msgID)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &printMsgs, sql, sqlParams)
|
||||||
|
return printMsgs, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrintMsgsFail(db *DaoDB, beginAt, endAt time.Time) (prints []*model.PrintMsg, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM print_msg
|
||||||
|
WHERE 1 = 1 AND deleted_at = ?
|
||||||
|
AND status <> ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{utils.DefaultTimeValue, 1}
|
||||||
|
if !utils.IsTimeZero(beginAt) {
|
||||||
|
sql += " AND created_at > ?"
|
||||||
|
sqlParams = append(sqlParams, beginAt)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(endAt) {
|
||||||
|
sql += " AND created_at < ?"
|
||||||
|
sqlParams = append(sqlParams, endAt)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &prints, sql, sqlParams)
|
||||||
|
return prints, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrinter(db *DaoDB, printNo string) (print *model.Printer, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT * FROM printer WHERE print_no = ? AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{printNo, utils.DefaultTimeValue}
|
||||||
|
err = GetRow(db, &print, sql, sqlParams)
|
||||||
|
return print, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePrintMsg 删除超过一个月时间的打印订单信息
|
||||||
|
func DeletePrintMsg() {
|
||||||
|
sql := ` DELETE FROM print_msg WHERE created_at < ?`
|
||||||
|
num, err := ExecuteSQL(GetDB(), sql, []interface{}{time.Now().AddDate(0, -1, 0)}...)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debugf("定时删除超过一个月的打印信息错误:%v", err)
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("定时删除超过一个月的打印信息:%d 条", num)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func QueryPrintList(db *DaoDB, printNo, printKey string, status, isOnline int64, page, size int64) (print []*model.Printer, count int, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS * FROM printer WHERE 1=1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += ` AND print_no = ?`
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if printKey != "" {
|
||||||
|
sql += ` AND print_key = ?`
|
||||||
|
sqlParams = append(sqlParams, printKey)
|
||||||
|
}
|
||||||
|
if status != model.PrintMsgAll {
|
||||||
|
sql += ` AND status = ?`
|
||||||
|
sqlParams = append(sqlParams, status)
|
||||||
|
}
|
||||||
|
if isOnline != model.PrintMsgAll {
|
||||||
|
sql += ` AND is_online = ?`
|
||||||
|
sqlParams = append(sqlParams, isOnline)
|
||||||
|
}
|
||||||
|
sql += ` AND deleted_at = ?`
|
||||||
|
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||||
|
sql += ` ORDER BY status desc,is_online desc LIMIT ? OFFSET ? `
|
||||||
|
sqlParams = append(sqlParams, size, page)
|
||||||
|
tx, _ := Begin(db)
|
||||||
|
if err = GetRowsTx(tx, &print, sql, sqlParams...); err != nil {
|
||||||
|
Rollback(db, tx)
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
count = GetLastTotalRowCountTx(tx)
|
||||||
|
defer Commit(db, tx)
|
||||||
|
|
||||||
|
return print, count, err
|
||||||
|
}
|
||||||
19
business/model/dao/dao_print_activation.go
Normal file
19
business/model/dao/dao_print_activation.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CheckHeard(printNo string) (bool, error) {
|
||||||
|
var data *model.PrintActivation
|
||||||
|
err := GetRow(GetDB(), &data, `SELECT * FROM print_activation WHERE print_no = ?`, []interface{}{printNo}...)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if data == nil {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
89
business/model/dao/dao_print_ex.go
Normal file
89
business/model/dao/dao_print_ex.go
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// QueryUserPrinter 查询用户打印机
|
||||||
|
func QueryUserPrinter(userId, printNo string) (*model.Printer, error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM printer
|
||||||
|
WHERE 1 = 1 AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
if printNo != "" {
|
||||||
|
sql += " AND print_no = ?"
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if userId != "" {
|
||||||
|
sql += " AND user_id = ?"
|
||||||
|
sqlParams = append(sqlParams, userId)
|
||||||
|
}
|
||||||
|
var printer = &model.Printer{}
|
||||||
|
err := GetRow(GetDB(), &printer, sql, sqlParams)
|
||||||
|
return printer, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrinters(db *DaoDB, appID int, printNo string, status, statusNeq int) (printers []*model.Printer, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM printer
|
||||||
|
WHERE 1 = 1 AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if appID != 0 {
|
||||||
|
sql += " AND app_id = ?"
|
||||||
|
sqlParams = append(sqlParams, appID)
|
||||||
|
}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += " AND print_no = ?"
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if status != 0 {
|
||||||
|
sql += " AND status = ?"
|
||||||
|
sqlParams = append(sqlParams, status)
|
||||||
|
}
|
||||||
|
if statusNeq != 0 {
|
||||||
|
sql += " AND status <> ?"
|
||||||
|
sqlParams = append(sqlParams, statusNeq)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &printers, sql, sqlParams)
|
||||||
|
|
||||||
|
return printers, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPrintMsgs2(db *DaoDB, printNo, msgID string, status, statusNeq int) (printMsgs []*model.PrintMsg, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM print_msg
|
||||||
|
WHERE 1 = 1 AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if status != model.PrintMsgAll {
|
||||||
|
sql += " AND status = ?"
|
||||||
|
sqlParams = append(sqlParams, status)
|
||||||
|
}
|
||||||
|
if statusNeq != model.PrintMsgAll {
|
||||||
|
sql += " AND status <> ?"
|
||||||
|
sqlParams = append(sqlParams, statusNeq)
|
||||||
|
}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += " AND print_no = ?"
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if msgID != "" {
|
||||||
|
sql += " AND msg_id = ?"
|
||||||
|
sqlParams = append(sqlParams, msgID)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &printMsgs, sql, sqlParams)
|
||||||
|
return printMsgs, err
|
||||||
|
}
|
||||||
25
business/model/dao/dao_print_setting.go
Normal file
25
business/model/dao/dao_print_setting.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPrintSetting(printNo string) (*model.PrintSettingObj, error) {
|
||||||
|
sql := ` SELECT * FROM print_setting WHERE print_no = ? and deleted_at = ? `
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
printNo,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
var printSetting *model.PrintSetting
|
||||||
|
if err := GetRow(GetDB(), &printSetting, sql, sqlParams...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if printSetting == nil {
|
||||||
|
return nil, errors.New("数据查询异常")
|
||||||
|
}
|
||||||
|
|
||||||
|
return model.UnMarshalString2Json(printSetting)
|
||||||
|
}
|
||||||
34
business/model/dao/dao_print_temp.go
Normal file
34
business/model/dao/dao_print_temp.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SelectUserDefaultTemp 查询用户默认模板
|
||||||
|
func SelectUserDefaultTemp(userId string, tempType string) (*model.SystemTemp, bool, error) {
|
||||||
|
var result *model.SystemTemp
|
||||||
|
if err := GetRow(GetDB(), &result, `SELECT * FROM system_temp WHERE user_id = ? AND temp_type = ? AND is_use = ? AND deleted_at = ? ORDER BY created_at desc `, []interface{}{userId, tempType, 1, utils.DefaultTimeValue}...); err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
return result, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// QuerySystemTemp 查询系统模板
|
||||||
|
func QuerySystemTemp() (*model.SystemTemp, error) {
|
||||||
|
var result []*model.SystemTemp
|
||||||
|
if err := GetRows(GetDB(), &result, `SELECT * FROM system_temp WHERE user_id = ? AND temp_type = ? AND is_use = ? AND deleted_at = ? ORDER BY created_at desc `, []interface{}{"system_user", "user_store", 1, utils.DefaultTimeValue}...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) > 0 {
|
||||||
|
return result[0], nil
|
||||||
|
}
|
||||||
|
return nil, errors.New("模板获取异常")
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTemp 添加模板数据
|
||||||
|
func AddTemp(param *model.SystemTemp) error {
|
||||||
|
return CreateEntity(GetDB(), param)
|
||||||
|
}
|
||||||
@@ -116,14 +116,14 @@ func GetUsers(db *DaoDB, userType int, keyword, popUser string, userIDs, userID2
|
|||||||
|
|
||||||
func GetUsers2(db *DaoDB, keyword string, userID string, pop int, mobile string, fromTime, toTime time.Time, timeType int, cityCodes, consumeTypes []int, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
func GetUsers2(db *DaoDB, keyword string, userID string, pop int, mobile string, fromTime, toTime time.Time, timeType int, cityCodes, consumeTypes []int, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
||||||
var (
|
var (
|
||||||
userList []*model.User
|
userList []*model.UserBalance
|
||||||
)
|
)
|
||||||
offset = jxutils.FormalizePageOffset(offset)
|
offset = jxutils.FormalizePageOffset(offset)
|
||||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
sqlParams := []interface{}{}
|
sqlParams := []interface{}{}
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT
|
SELECT SQL_CALC_FOUND_ROWS DISTINCT
|
||||||
a.*
|
a.*,ub.account_balance
|
||||||
FROM user a`
|
FROM user a`
|
||||||
for _, v := range consumeTypes {
|
for _, v := range consumeTypes {
|
||||||
switch v {
|
switch v {
|
||||||
@@ -171,6 +171,7 @@ func GetUsers2(db *DaoDB, keyword string, userID string, pop int, mobile string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sql += ` JOIN user_bill ub ON ub.user_id = a.user_id`
|
||||||
sql += `
|
sql += `
|
||||||
WHERE a.status = 1 AND a.deleted_at = ?`
|
WHERE a.status = 1 AND a.deleted_at = ?`
|
||||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||||
@@ -435,3 +436,19 @@ func GetUserUnionBindImg(db *DaoDB, unionID, actID string) (userBinds *model.Use
|
|||||||
err = GetRow(db, &userBinds, sql, sqlParams)
|
err = GetRow(db, &userBinds, sql, sqlParams)
|
||||||
return userBinds, err
|
return userBinds, err
|
||||||
}
|
}
|
||||||
|
func GetUserVendorOrder(db *DaoDB, userID, localWayBill string) (userVendorOrder *model.UserVendorOrder, err error) {
|
||||||
|
sql := `SELECT * FROM user_vendor_order WHERE deleted_at = ? `
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if userID != "" {
|
||||||
|
sql += "AND user_id = ?"
|
||||||
|
sqlParams = append(sqlParams, userID)
|
||||||
|
}
|
||||||
|
if localWayBill != "" {
|
||||||
|
sql += " AND local_way_bill = ?"
|
||||||
|
sqlParams = append(sqlParams, localWayBill)
|
||||||
|
}
|
||||||
|
err = GetRow(db, &userVendorOrder, sql, sqlParams)
|
||||||
|
return userVendorOrder, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package dao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetUsers(t *testing.T) {
|
func TestGetUsers(t *testing.T) {
|
||||||
userList, _, err := GetUsers(GetDB(), 0, "", nil, nil, []string{"18180948107"}, 0, 0)
|
//userList, _, err := GetUsers(GetDB(), 0, "", nil, nil, []string{"18180948107"}, 0, 0)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
//}
|
||||||
t.Log(utils.Format4Output(userList, false))
|
//t.Log(utils.Format4Output(userList, false))
|
||||||
}
|
}
|
||||||
|
|||||||
15
business/model/dao/print_activation.go
Normal file
15
business/model/dao/print_activation.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NotExistsCreate(printNo string) error {
|
||||||
|
item := &model.PrintActivation{
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
PrintNo: printNo,
|
||||||
|
}
|
||||||
|
|
||||||
|
return CreateOrUpdate(GetDB(), item)
|
||||||
|
}
|
||||||
28
business/model/dao/print_bill.go
Normal file
28
business/model/dao/print_bill.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeductionPrintBalance 扣除打印机账号余额
|
||||||
|
/*func DeductionPrintBalance(db *DaoDB, printNo string) error {
|
||||||
|
_, err := ExecuteSQL(db, `UPDATE print_bill SET print_balance = print_balance -1 WHERE print_no = ?`, []interface{}{printNo}...)
|
||||||
|
return err
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// DeductionPrintBalance 扣除打印机账号余额
|
||||||
|
func DeductionPrintBalance(db *DaoDB, printNo string) error {
|
||||||
|
var data *model.PrintBill
|
||||||
|
if err := GetRow(db, &data, `SELECT * FROM print_bill WHERE print_no = ?`, []interface{}{printNo}...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if data == nil {
|
||||||
|
return errors.New("数据异常")
|
||||||
|
}
|
||||||
|
|
||||||
|
data.PrintBalance -= 1
|
||||||
|
_, err := UpdateEntity(db, data, "print_balance")
|
||||||
|
return err
|
||||||
|
}
|
||||||
32
business/model/dao/print_bill_record.go
Normal file
32
business/model/dao/print_bill_record.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// QueryOrderDeductionRecord 查询订单扣除记录
|
||||||
|
func QueryOrderDeductionRecord(db *DaoDB, printNo string, orderNo string) (bool, error) {
|
||||||
|
sql := `SELECT * FROM print_bill_record WHERE print_no = ? AND order_id = ? AND created_at > ? AND created_at < ?`
|
||||||
|
|
||||||
|
timeNow := time.Now()
|
||||||
|
startTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
|
||||||
|
endTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
|
||||||
|
param := []interface{}{printNo, orderNo, startTime, endTime}
|
||||||
|
|
||||||
|
var result []*model.PrintBillRecord
|
||||||
|
if err := GetRows(db, &result, sql, param...); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) == 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPrintRecord 添加打印记录
|
||||||
|
func AddPrintRecord(db *DaoDB, param *model.PrintBillRecord) error {
|
||||||
|
return CreateEntity(db, param)
|
||||||
|
}
|
||||||
42
business/model/dao/print_bind_store.go
Normal file
42
business/model/dao/print_bind_store.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// QueryPrintBindStore 查询绑定门店
|
||||||
|
func QueryPrintBindStore(printNo string) ([]*model.PrintBindStore, error) {
|
||||||
|
var data []*model.PrintBindStore
|
||||||
|
if err := GetRows(GetDB(), &data, `SELECT * FROM print_bind_store WHERE print_no = ?`, []interface{}{printNo}...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BindStoreList 绑定门店信息
|
||||||
|
func BindStoreList(req *model.AddPrinterParam, userId string) error {
|
||||||
|
param := &model.PrintBindStore{
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
|
StoreID: req.StoreId,
|
||||||
|
StoreName: req.Name,
|
||||||
|
StoreVendor: 9, // 绑定平台,全平台
|
||||||
|
PrintNo: req.PrintNo,
|
||||||
|
StoreStatus: 1, // 门店开启
|
||||||
|
BindStatus: 1, // 绑定状态
|
||||||
|
}
|
||||||
|
if userId != "" {
|
||||||
|
param.UserId = userId
|
||||||
|
} else {
|
||||||
|
param.UserId = "system"
|
||||||
|
}
|
||||||
|
return CreateEntity(GetDB(), param)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteStoreList 删除绑定门店
|
||||||
|
func DeleteStoreList(printNo string, storeId string) error {
|
||||||
|
sql := ` DELETE FROM print_bind_store WHERE print_no = ? AND store_id = ? `
|
||||||
|
_, err := ExecuteSQL(GetDB(), sql, []interface{}{printNo, storeId}...)
|
||||||
|
return err
|
||||||
|
}
|
||||||
547
business/model/dao/print_temp_utils.go
Normal file
547
business/model/dao/print_temp_utils.go
Normal file
@@ -0,0 +1,547 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var SystemTempObj map[string]*model.SystemTemp
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
SystemTempObj = make(map[string]*model.SystemTemp, 0)
|
||||||
|
sysTempList, err := QuerySystemTemp()
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debug("query system temp err :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
SystemTempObj[sysTempList.TempSize] = sysTempList
|
||||||
|
|
||||||
|
//now := time.Now()
|
||||||
|
//param := &model.SystemTemp{
|
||||||
|
// CreatedAt: &now,
|
||||||
|
// UpdatedAt: &now,
|
||||||
|
// LastOperator: "system",
|
||||||
|
// DeletedAt: &utils.DefaultTimeValue,
|
||||||
|
// TempName: "",
|
||||||
|
// TempRank: model.SystemTempKey,
|
||||||
|
// Temp: "",
|
||||||
|
// UserId: "system_user",
|
||||||
|
// TempType: model.TempTypeMerchant,
|
||||||
|
// TempSize: model.SystemTempSizeBig,
|
||||||
|
// PrintSn: "system",
|
||||||
|
// IsUse: 1,
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 初始化大字体模板
|
||||||
|
//if _, v := temp[model.SystemTempSizeBig]; !v {
|
||||||
|
// param.TempName = "system" + model.SystemTempSizeBig
|
||||||
|
// param.Temp = model.SystemTempValue
|
||||||
|
// if err := AddTemp(param); err != nil {
|
||||||
|
// globals.SugarLogger.Debug("init system temp err :", err)
|
||||||
|
// }
|
||||||
|
// SystemTempObj[model.SystemTempSizeBig] = param
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 初始化中字体模板
|
||||||
|
//if _, v := temp[model.SystemTempSizeMedium]; !v {
|
||||||
|
// param.TempName = "system" + model.SystemTempSizeMedium
|
||||||
|
// medium := strings.Replace(model.SystemTempValue, "<b>", "<hb>", -1)
|
||||||
|
// medium2 := strings.Replace(medium, "</b>", "</hb>", -1)
|
||||||
|
// param.Temp = medium2
|
||||||
|
// param.TempSize = model.SystemTempSizeMedium
|
||||||
|
// param.IsUse = 2
|
||||||
|
// if err := AddTemp(param); err != nil {
|
||||||
|
// globals.SugarLogger.Debug("init system temp err :", err)
|
||||||
|
// }
|
||||||
|
// SystemTempObj[model.SystemTempSizeMedium] = param
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 初始化小字体模板
|
||||||
|
//if _, v := temp[model.SystemTempSizeSmall]; !v {
|
||||||
|
// param.TempName = "system" + model.SystemTempSizeSmall
|
||||||
|
// medium := strings.Replace(model.SystemTempValue, "<b>", " ", -1)
|
||||||
|
// medium2 := strings.Replace(medium, "</b>", " ", -1)
|
||||||
|
// param.Temp = medium2
|
||||||
|
// param.TempSize = model.SystemTempSizeSmall
|
||||||
|
// param.IsUse = 2
|
||||||
|
// if err := AddTemp(param); err != nil {
|
||||||
|
// globals.SugarLogger.Debug("init system temp err :", err)
|
||||||
|
// }
|
||||||
|
// SystemTempObj[model.SystemTempSizeSmall] = param
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakePrintMsgOnTemp 将打印数据渲染到模板当中
|
||||||
|
func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error) {
|
||||||
|
// 查询用户默认模板,不存在则使用系统默认模板
|
||||||
|
userTemp := &model.SystemTemp{}
|
||||||
|
userTemp, isHave, err := SelectUserDefaultTemp(userId, model.TempTypeMerchantUser)
|
||||||
|
if err != nil || !isHave {
|
||||||
|
userTemp, err = QuerySystemTemp()
|
||||||
|
}
|
||||||
|
if userTemp == nil || !isHave || err != nil {
|
||||||
|
if userTemp.TempType != "" {
|
||||||
|
userTemp = SystemTempObj[userTemp.TempSize]
|
||||||
|
} else {
|
||||||
|
userTemp = SystemTempObj[model.SystemTempSizeBig]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 需要打印数据
|
||||||
|
printMsg := ""
|
||||||
|
printValue := make([]interface{}, 0, 0)
|
||||||
|
userTempMap := make(map[string]string, 0)
|
||||||
|
if err := json.Unmarshal([]byte(userTemp.Temp), &userTempMap); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range strings.Split(userTemp.TempRank, ",") {
|
||||||
|
switch v {
|
||||||
|
case "skuName", "skuNumber", "skuPrice", "skuAllPrice", "allSkuTypeCount", "allSkuCount", "skuUpc", "userPayMoney":
|
||||||
|
continue
|
||||||
|
case "goodsListDetail":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
skuList := make([]*model.SkuListPrintOrder, 0, 0)
|
||||||
|
if err := json.Unmarshal([]byte(param["skuList"]), &skuList); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
for i := 0; i < len(skuList); i++ {
|
||||||
|
printMsg += userTempMap["skuName"]
|
||||||
|
printMsg += userTempMap["skuNumber"]
|
||||||
|
//printMsg += userTempMap["skuPrice"]
|
||||||
|
//printMsg += userTempMap["skuAllPrice"]
|
||||||
|
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuCount /*skuList[i].SalePrice, skuList[i].TotalCountPrice*/)
|
||||||
|
//if skuList[i].Upc != "" {
|
||||||
|
// printMsg += userTempMap["skuUpc"]
|
||||||
|
// printValue = append(printValue, skuList[i].Upc)
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
printMsg += userTempMap["allSkuTypeCount"]
|
||||||
|
printValue = append(printValue, param["allSkuTypeCount"])
|
||||||
|
printMsg += userTempMap["allSkuCount"]
|
||||||
|
printValue = append(printValue, param["allSkuCount"])
|
||||||
|
printMsg += userTempMap["userPayMoney"]
|
||||||
|
printValue = append(printValue, param["userPayMoney"])
|
||||||
|
case "businessType":
|
||||||
|
if param[v] == "2" { // 是预订单
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param[v])
|
||||||
|
}
|
||||||
|
case "divider":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
case "title":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
case "qrcOrder": // 老版打印机展示不要
|
||||||
|
//printMsg += `<b>%s #%s</b>`
|
||||||
|
//printValue = append(printValue, param["vendorName"], param["vendorOrderNo"])
|
||||||
|
if param["vendorName"] == "京东到家" {
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param[v])
|
||||||
|
}
|
||||||
|
case "vendorName":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param[v], param["vendorOrderNo"])
|
||||||
|
case "storeName2":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param["storeName"])
|
||||||
|
default:
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param[v])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return strings.Replace(fmt.Sprintf(strings.Replace(printMsg, "\n", "", -1), printValue...), "\\n", "\r\n", -1), nil
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakePrintMsgOnTempVoice 制作平台语音
|
||||||
|
func MakePrintMsgOnTempVoice(param map[string]string, setting *model.PrintSettingObj, userId string) (string, error) {
|
||||||
|
// 打订单
|
||||||
|
if param[model.OrderStatusPrint] != "" {
|
||||||
|
// 订单提示设置
|
||||||
|
printMsg, err := PrinterOrderVoice(param, setting, userId)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debug("err Unmarshal userTemp.printMsg", err)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return printMsg, nil
|
||||||
|
}
|
||||||
|
// 打运单
|
||||||
|
if param[model.WayBillStatusPrint] != "" {
|
||||||
|
switch param[model.WayBillStatusPrint] {
|
||||||
|
case utils.Int2Str(model.WaybillStatusCourierAssigned): // 分配骑手
|
||||||
|
return PrintWayBillOrderStatus(param, setting), nil
|
||||||
|
case utils.Int2Str(model.WaybillStatusDeliverReminder): // 催单
|
||||||
|
printVoiceMsg := ``
|
||||||
|
printVoiceValue := make([]interface{}, 0, 0)
|
||||||
|
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.ReminderOrderVoice)
|
||||||
|
return strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1), nil
|
||||||
|
case utils.Int2Str(model.WaybillStatusDelivered): // 送达
|
||||||
|
printVoiceMsg := ``
|
||||||
|
printVoiceValue := make([]interface{}, 0, 0)
|
||||||
|
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.FinialsOrderVoice)
|
||||||
|
return strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 门店状态
|
||||||
|
if param[model.StoreStatusPrint] != "" {
|
||||||
|
return PrintStoreStatus(param, setting), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 进店咨询
|
||||||
|
if param[model.EnterTheStorePrint] != "" && setting.VoiceSetting.ConsultingPrint == model.SettingOpen {
|
||||||
|
return `<sound>19</sound>`, nil
|
||||||
|
}
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrinterOrderVoice 打印机订单提示设置
|
||||||
|
func PrinterOrderVoice(param map[string]string, setting *model.PrintSettingObj, userId string) (string, error) {
|
||||||
|
var (
|
||||||
|
printVoiceMsg string //语音信息
|
||||||
|
printVoiceValue = make([]interface{}, 0, 0)
|
||||||
|
textMsg string // 文本信息
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
// 订单状态
|
||||||
|
switch param[model.OrderStatusPrint] {
|
||||||
|
// 新订单(待接单)
|
||||||
|
case utils.Int2Str(model.OrderStatusNew), utils.Int2Str(model.OrderStatusAccepted): // utils.Int2Str(model.OrderStatusFinishedPickup), utils.Int2Str(model.OrderStatusAccepted)
|
||||||
|
//if param[model.OrderStatusPrint] != utils.Int2Str(model.OrderStatusNew) && param[model.VendorIDPrint] == utils.Int64ToStr(model.VendorIDMTWM) {
|
||||||
|
// return "", err
|
||||||
|
//}
|
||||||
|
//if param[model.OrderStatusPrint] == utils.Int2Str(model.OrderStatusFinishedPickup) && param[model.VendorIDPrint] == utils.Int64ToStr(model.VendorIDEBAI) {
|
||||||
|
// return "", err
|
||||||
|
//}
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
// 订单设置
|
||||||
|
if setting.PrintSetting.WaitOrderPrint == model.SettingOpen { // 打印订单
|
||||||
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if setting.VoiceSetting.WaitOrderVoice == model.SettingOpen { // 订单通知
|
||||||
|
printVoiceMsg += `<sound>%d</sound>` // 你来新订单了
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NewOrderVoice)
|
||||||
|
}
|
||||||
|
// 申请取消
|
||||||
|
case utils.Int2Str(model.ApplyOrderCancel):
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
// 订单设置
|
||||||
|
if setting.PrintSetting.ApplyUserCancelOrder == model.SettingOpen { // 申请取消打印
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>客户申请取消订单:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejection += `<center><b>取消时间: %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], utils.Time2DateStr(time.Now()))
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
if setting.VoiceSetting.ApplyUserOrderCancelVoice == model.SettingOpen { // 申请取消语音
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.ApplyCancelVoice)
|
||||||
|
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||||
|
}
|
||||||
|
// 申请退货
|
||||||
|
case utils.Int2Str(model.ApplyOrderRefundGoods):
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>客户申请退货:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejection += `<center><b>原因: %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.RejectionReasonPrint])
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
|
||||||
|
if setting.VoiceSetting.ApplyRefundGoodsVoice == model.SettingOpen { // 申请退货语音
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.ApplyReturnGoodsVoice)
|
||||||
|
// printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||||
|
}
|
||||||
|
// 申请退款
|
||||||
|
case utils.Int2Str(model.ApplyOrderRefund):
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
// 订单设置
|
||||||
|
if setting.PrintSetting.ApplyUserRefund == model.SettingOpen { // 取消退款订单
|
||||||
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if setting.VoiceSetting.ApplyRefundOrderVoice == model.SettingOpen {
|
||||||
|
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.ApplyRefundVoice)
|
||||||
|
}
|
||||||
|
// 取消打印
|
||||||
|
|
||||||
|
case utils.Int2Str(model.OrderStatusRejection): // 拒收
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
//if setting.VoiceSetting.CustomerRejectionVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
||||||
|
// // 暂无语音打印
|
||||||
|
//}
|
||||||
|
// 拒收暂无语音设置,使用文本提示
|
||||||
|
if setting.PrintSetting.CustomerRejectionPrint == model.SettingOpen { // 客户拒收打印
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>客户拒收信息:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejection += `<center><b>拒收原因: %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.RejectionReasonPrint])
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
case utils.Int2Str(model.OrderStatusCustomerService): // 客服退款
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
if setting.VoiceSetting.CusterRefundVoice == model.SettingOpen {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.BusinessResponsibilityVoice)
|
||||||
|
}
|
||||||
|
if setting.PrintSetting.CusterRefundPrint == model.SettingOpen {
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>客服退款详情:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejection += `<center><b>退款原因: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>退款时间: %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.CustcareRefundReasonPrint], utils.Time2DateStr(time.Now()))
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
case utils.Int2Str(model.OrderStatusCanceled), utils.Int2Str(model.CancelOrderSuccess): // 取消订单成功
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
if setting.VoiceSetting.RefundGoodsVoice == model.SettingOpen {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.CancelOrderVoice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if setting.PrintSetting.CusterRefundPrint == model.SettingOpen {
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>订单取消成功:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejection += `<center><b>取消原因: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>取消成功时间: %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.CustcareRefundReasonPrint], utils.Time2DateStr(time.Now()))
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
case utils.Int2Str(model.BusinessCancelOrder): // 商家取消打印
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
if setting.PrintSetting.BusinessOrderCancel == model.SettingOpen {
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>商家侧取消订单:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejection += `<center><b>取消原因: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>取消成功时间: %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.CustcareRefundReasonPrint], utils.Time2DateStr(time.Now()))
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
case utils.Int2Str(model.OrderRefundMoneySuccess): // 订单退款成功打印
|
||||||
|
// 称谓设置/平台语音设置
|
||||||
|
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||||
|
// 老板
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||||
|
}
|
||||||
|
if setting.PrintSetting.OrderCancelSuccess == model.SettingOpen {
|
||||||
|
rejection := ``
|
||||||
|
rejectionValue := make([]interface{}, 0, 0)
|
||||||
|
rejection += `<center><b>退款成功:</b></center><br>`
|
||||||
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
||||||
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
||||||
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint])
|
||||||
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
voice := strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||||
|
return voice + textMsg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintWayBillOrderStatus 打印运单类通知消息
|
||||||
|
func PrintWayBillOrderStatus(param map[string]string, setting *model.PrintSettingObj) string {
|
||||||
|
var (
|
||||||
|
printVoiceMsg string //语音信息
|
||||||
|
printVoiceValue = make([]interface{}, 0, 0)
|
||||||
|
textMsg string // 文本信息
|
||||||
|
textMsgValue = make([]interface{}, 0, 0) // 文本信息
|
||||||
|
)
|
||||||
|
|
||||||
|
switch param[model.WayBillStatusPrint] {
|
||||||
|
case utils.Int2Str(model.WaybillStatusAccepted), utils.Int2Str(model.WaybillStatusCourierAssigned): // 分配骑手
|
||||||
|
if setting.PrintSetting.RiderTakeOrder == model.SettingOpen { // 打印订单
|
||||||
|
textMsg += `<center><b>接单骑手信息:</b></center><br>`
|
||||||
|
textMsg += `<center><b>骑手姓名: %s</b></center><br>`
|
||||||
|
textMsg += `<center><b>骑手电话: %s</b></center><br>`
|
||||||
|
textMsg += `<center><b>接单时间: %s</b></center><br>`
|
||||||
|
textMsg += `<center><b>订单来源: %s</b></center><br>`
|
||||||
|
textMsg += `<center><b>单号: #%s</b></center><br>`
|
||||||
|
textMsgValue = append(textMsgValue, param[model.RiderNamePrint], param[model.RiderPhonePrint], utils.Time2DateStr(time.Now()), param[model.VendorNamePrint], param[model.VendorOrderNoPrint])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if setting.VoiceSetting.RiderTakeOrderVoice == model.SettingOpen { // 骑手接单语音通知
|
||||||
|
printVoiceMsg += `<sound>%d</sound><sound>%d</sound>` // 骑手已经接单了
|
||||||
|
printVoiceValue = append(printVoiceValue, model.RiderGetOrderVoice)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
||||||
|
voice := strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||||
|
return voice + msg
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintStoreStatus 打印门店状态
|
||||||
|
func PrintStoreStatus(param map[string]string, setting *model.PrintSettingObj) string {
|
||||||
|
var (
|
||||||
|
printVoiceMsg string //语音信息
|
||||||
|
printVoiceValue = make([]interface{}, 0, 0)
|
||||||
|
textMsg string // 文本信息
|
||||||
|
textMsgValue = make([]interface{}, 0, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
switch utils.Str2Int(param[model.StoreStatusPrint]) {
|
||||||
|
case -9: // 丢失授权
|
||||||
|
var voice string
|
||||||
|
if setting.VoiceSetting.LoseAuthorization == model.SettingOpen {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.LoseTokenVoice)
|
||||||
|
voice = strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
textMsg += `<left><b>门店丢失授权通知</b></left><br>`
|
||||||
|
textMsg += `<left><b>门店:%s</b></left><br>`
|
||||||
|
textMsg += `<left><b>平台:%s</b></left><br>`
|
||||||
|
textMsg += `<left><b>下线时间:%s</b></left><br>`
|
||||||
|
textMsg += `<left><b>授权丢失,将无法继续打压订单!!!!</b></left><br>`
|
||||||
|
textMsgValue = append(textMsgValue, param[model.StoreNamePrint], param[model.VendorNamePrint], utils.Time2DateStr(time.Now()))
|
||||||
|
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
||||||
|
return voice + msg
|
||||||
|
default:
|
||||||
|
// 离线打印文本开启
|
||||||
|
textMsg += `<center><b>门店下线通知</b></center><br>`
|
||||||
|
textMsg += `<center><b>门店:%s</b></center><br>`
|
||||||
|
textMsg += `<center><b>平台:%s</b></center><br>`
|
||||||
|
textMsg += `<center><b>下线时间:%s</b></center><br>`
|
||||||
|
textMsgValue = append(textMsgValue, param[model.StoreNamePrint], param[model.VendorNamePrint], utils.Time2DateStr(time.Now()))
|
||||||
|
// 离线打印语音开启
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.StoreOfflineVoice)
|
||||||
|
voice := strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||||
|
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
||||||
|
|
||||||
|
return voice + msg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyntheticSpeech 合成语音 (美团xxx号订单)
|
||||||
|
func SyntheticSpeech(printVoiceMsg string, printVoiceValue []interface{}, param map[string]string) (string, []interface{}) {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>` // 美团
|
||||||
|
switch param[model.VendorIDPrint] {
|
||||||
|
case utils.Int2Str(model.VendorIDJD): // 京东
|
||||||
|
printVoiceValue = append(printVoiceValue, model.JdVoice)
|
||||||
|
case utils.Int2Str(model.VendorIDMTWM): // 美团
|
||||||
|
printVoiceValue = append(printVoiceValue, model.MtVoice)
|
||||||
|
case utils.Int2Str(model.VendorIDEBAI): // 饿了么
|
||||||
|
printVoiceValue = append(printVoiceValue, model.ElmVoice)
|
||||||
|
case utils.Int2Str(model.VendorIDEBAI): // 饿百
|
||||||
|
printVoiceValue = append(printVoiceValue, model.ElmVoice)
|
||||||
|
case utils.Int2Str(model.VendorIDJDShop): // 京东商城
|
||||||
|
printVoiceValue = append(printVoiceValue, model.JdToHose)
|
||||||
|
case utils.Int2Str(model.VendorIDTT): // 抖音
|
||||||
|
// 暂无
|
||||||
|
}
|
||||||
|
if param[model.VendorOrderNoPrint] != "" {
|
||||||
|
switch len(param[model.VendorOrderNoPrint]) {
|
||||||
|
case 1:
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint]])
|
||||||
|
case 2:
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][:1]+"0"])
|
||||||
|
if param[model.VendorOrderNoPrint][1:] != "0" {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:]])
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][0:1]+"00"])
|
||||||
|
if param[model.VendorOrderNoPrint][1:2] == "0" && param[model.VendorOrderNoPrint][2:] == "0" {
|
||||||
|
|
||||||
|
} else if param[model.VendorOrderNoPrint][1:2] == "0" && param[model.VendorOrderNoPrint][2:] != "0" {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]])
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][2:]])
|
||||||
|
} else if param[model.VendorOrderNoPrint][1:2] != "0" && param[model.VendorOrderNoPrint][2:] == "0" {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]+"0"])
|
||||||
|
} else if param[model.VendorOrderNoPrint][1:2] != "0" && param[model.VendorOrderNoPrint][2:] != "0" {
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]+"0"])
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][2:]])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printVoiceMsg += `<sound>%d</sound>`
|
||||||
|
printVoiceValue = append(printVoiceValue, model.OrderNoVoice)
|
||||||
|
return printVoiceMsg, printVoiceValue
|
||||||
|
}
|
||||||
14
business/model/dao/user_delivery_address.go
Normal file
14
business/model/dao/user_delivery_address.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetAddressDetail(id int) (*model.UserDeliveryAddress, error) {
|
||||||
|
param := &model.UserDeliveryAddress{}
|
||||||
|
param.ModelIDCULD.ID = id
|
||||||
|
if err := GetEntity(GetDB(), param, "ID"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return param, nil
|
||||||
|
}
|
||||||
@@ -20,6 +20,12 @@ const (
|
|||||||
|
|
||||||
ErrCodeAccountBalanceNotEnough = "-201" //余额不足
|
ErrCodeAccountBalanceNotEnough = "-201" //余额不足
|
||||||
ErrCodeNotAuthBindWeixin = "-202" //没有绑定微信认证方式
|
ErrCodeNotAuthBindWeixin = "-202" //没有绑定微信认证方式
|
||||||
|
|
||||||
|
// 打印机错误
|
||||||
|
ErrCodeOpenAPIParamErrMethod = "-1001" //参数错误,method
|
||||||
|
ErrCodeOpenAPIParamErrTimeStamp = "-1002" //参数错误,timestamp
|
||||||
|
ErrCodeOpenAPIParamErrSign = "-1003" //参数错误,sign
|
||||||
|
ErrCodeOpenAPIParamErrNormal = "-1000" //api非通用参数错误
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package model
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PayTypeWX = 1 // 微信支付
|
PayTypeWX = 1 // 微信支付
|
||||||
PayTypeTL = 2 // 通联宝支付
|
PayTypeTL = 2 // 通联宝支付
|
||||||
|
PayTypeAliPay = 3 // 支付包
|
||||||
|
|
||||||
PayStatusNo = 0
|
PayStatusNo = 0
|
||||||
PayStatusYes = 1
|
PayStatusYes = 1
|
||||||
@@ -18,6 +19,21 @@ const (
|
|||||||
|
|
||||||
VendorPayTypeCompanyPay = "companyPay" //企业付款
|
VendorPayTypeCompanyPay = "companyPay" //企业付款
|
||||||
VendorPayTypeTransferAccount = "transferAccount" //手动转账
|
VendorPayTypeTransferAccount = "transferAccount" //手动转账
|
||||||
|
|
||||||
|
PayType4Member = 1 // 购买会员
|
||||||
|
PayType4Recharge = 2 // 充值余额
|
||||||
|
PayType4Express = 3 // 支付快递
|
||||||
|
|
||||||
|
//订单支付方式
|
||||||
|
OrderPayMethodBalance = 1 //余额支付
|
||||||
|
OrderPayMethodWX = 2 //微信支付
|
||||||
|
OrderPayMethodMix = 5 //余额+微信混合支付
|
||||||
|
|
||||||
|
OrderNotPay = 2 //订单待支付
|
||||||
|
PayChooseBalance = 1 //选中余额支付
|
||||||
|
PayNotChooseBalance = -1 //不选中余额支付
|
||||||
|
//UserVendorOrder订单状态
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -25,9 +41,12 @@ const (
|
|||||||
OrderTypeCash = 2 //提现
|
OrderTypeCash = 2 //提现
|
||||||
|
|
||||||
OrderTypePublishJob = 1 //发布任务
|
OrderTypePublishJob = 1 //发布任务
|
||||||
OrderTpyeMember = 2 //充值会员
|
OrderTypeMember = 2 //充值会员月卡
|
||||||
|
OrderTypeMemberYear = 5 //充值会员年卡
|
||||||
OrderTypeDelivery = 3 //发快递
|
OrderTypeDelivery = 3 //发快递
|
||||||
OrderTpyeDropShipping = 4 //一件代发交钱
|
OrderTypeDropShipping = 4 //一件代发交钱
|
||||||
|
OrderTypeMobile = 7 //充话费
|
||||||
|
OrderTypeBalance = 6 //余额充值
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -46,26 +65,31 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Order 提现记录不在做在这表里面
|
||||||
type Order struct {
|
type Order struct {
|
||||||
ModelIDCUL
|
ModelIDCUL
|
||||||
|
|
||||||
OrderID string `orm:"column(order_id)" json:"orderID"` //订单号
|
OrderID string `orm:"column(order_id)" json:"orderID"` // 订单号
|
||||||
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
UserID string `orm:"column(user_id);size(48)" json:"userID"` // 用户ID
|
||||||
Type int `json:"type"`
|
Type int `json:"type"` // 支付还是提现 1-支付,2-提现
|
||||||
OrderType int `json:"orderType"` //订单类型
|
OrderType int `json:"orderType"` // 订单类型,1-发任务,2-会员月卡,3-发快递,4-提现,5-会员年卡,6-使用充值到余额方式的订单,7-话费
|
||||||
Way string `json:"way"` //weixinapp ,weixinmini
|
Way string `json:"way"` // weixinapp ,weixinmini
|
||||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
Status int `json:"status"` // 订单状态,待支付2,已支付5,支付成功110,支付失败115,150取消
|
||||||
PayPrice int `json:"payPrice"` //支付金额
|
PayPrice int `json:"payPrice"` // 支付金额
|
||||||
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
||||||
PayFinishedAt time.Time `orm:"type(datetime);null" json:"payFinishedAt"`
|
PayFinishedAt time.Time `orm:"type(datetime);null" json:"payFinishedAt"` // 支付完成时间
|
||||||
PrepayID string `orm:"column(prepay_id);size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
PrepayID string `orm:"column(prepay_id);size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
||||||
OriginalData string `orm:"type(text)" json:"-"`
|
OriginalData string `orm:"type(text)" json:"-"` //
|
||||||
Comment string `orm:"size(255)" json:"comment"` //备注
|
Comment string `orm:"size(255)" json:"comment"` // 备注
|
||||||
Lng float64 `json:"lng"`
|
Lng float64 `json:"lng"` // 坐标
|
||||||
Lat float64 `json:"lat"`
|
Lat float64 `json:"lat"` // 坐标
|
||||||
CityCode int `orm:"default(0)" json:"cityCode"` //提交订单时用户所在城市
|
CityCode int `orm:"default(0)" json:"cityCode"` // 提交订单时用户所在城市
|
||||||
DistrictCode int `orm:"default(0)" json:"districtCode"`
|
DistrictCode int `orm:"default(0)" json:"districtCode"` // 城市code
|
||||||
Address string `orm:"size(255)" json:"address"`
|
Address string `orm:"size(255)" json:"address"` // 地址
|
||||||
|
PayMethod int `orm:"size(255)" json:"payMethod"` // 支付方式1-余额支付,2-微信支付,3-微信提现,4-支付宝提现 5-余额+微信混合支付
|
||||||
|
Mobile string `orm:"size(15)" json:"mobile"` // 电话话费充值时使用
|
||||||
|
FlowCode string `orm:"size(15)" json:"flowCode"` // 电话话费充值时使用
|
||||||
|
RechargeStatus int `orm:"size(2)" json:"rechargeStatus"` // 充值状态 0-未提交,3-等待待充值(本地) 1:充值中(三方),2:已充值,-1:失败(三方)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Order) TableUnique() [][]string {
|
func (v *Order) TableUnique() [][]string {
|
||||||
@@ -181,3 +205,9 @@ type UnionOrderStatus struct {
|
|||||||
OrderStatusAt time.Time `json:"orderStatusAt"` //更新时间
|
OrderStatusAt time.Time `json:"orderStatusAt"` //更新时间
|
||||||
Comment string `orm:"size(255)" json:"comment"` //备注
|
Comment string `orm:"size(255)" json:"comment"` //备注
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RechargeUserModelData 充值列表
|
||||||
|
type RechargeUserModelData struct {
|
||||||
|
Order
|
||||||
|
Name string `json:"name" db:"name"`
|
||||||
|
}
|
||||||
|
|||||||
22
business/model/order_pay_refund.go
Normal file
22
business/model/order_pay_refund.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type OrderPayRefund struct {
|
||||||
|
ModelIDCULD
|
||||||
|
RefundID string `orm:"column(refund_id);unique;size(48)" json:"refundID"` // 三方运单Id
|
||||||
|
VendorRefundID string `orm:"column(vendor_refund_id);unique;size(48)" json:"vendorRefundID"` // 支付方退款成功后生成的退款单号
|
||||||
|
VendorOrderID string `orm:"column(vendor_order_id);index;size(48)" json:"vendorOrderID"`
|
||||||
|
TransactionID string `orm:"column(transaction_id);index;size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
||||||
|
Status int `json:"status"`
|
||||||
|
RefundCreatedAt time.Time `orm:"type(datetime);index" json:"payCreatedAt"`
|
||||||
|
RefundFinishedAt *time.Time `orm:"type(datetime);null" json:"payFinishedAt"`
|
||||||
|
RefundFee int `json:"refundFee"`
|
||||||
|
OriginalData string `orm:"type(text)" json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *OrderPayRefund) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"ID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
143
business/model/print.go
Normal file
143
business/model/print.go
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type PrintMsg struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
PrintNo string `json:"print_no" db:"print_no"` //打印机编号
|
||||||
|
Content string `orm:"type(text)" json:"content" db:"content"` //订单内容
|
||||||
|
OrderNo string `json:"order_no" db:"order_no"` //订单序号
|
||||||
|
Status int `json:"status" db:"status"` //打印状态
|
||||||
|
Comment string `json:"comment" db:"comment"` //失败原因
|
||||||
|
MsgID string `orm:"column(msg_id)" json:"msgID" db:"msg_id"`
|
||||||
|
ContentEncryption string `orm:"type(text)" json:"content_encryption" db:"content_encryption"` //订单类容进制文件
|
||||||
|
}
|
||||||
|
|
||||||
|
type Printer struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
AppID int `orm:"column(app_id)" json:"app_id" db:"app_id"` //应用编号
|
||||||
|
PrintNo string `json:"print_no" db:"print_no"` //打印机编号
|
||||||
|
PrintKey string `json:"print_key" db:"print_key"` //打印机识别码
|
||||||
|
Name string `json:"name" db:"name"` //打印机备注名
|
||||||
|
Status int `json:"status" db:"status"` //打印机状态
|
||||||
|
IsOnline int `json:"is_online" db:"is_online"` //1在线,0离线
|
||||||
|
IccID string `orm:"column(icc_id)" json:"iccid" db:"icc_id"` //sim卡号
|
||||||
|
Sound string `json:"sound" db:"sound"` //声音类型 sounda ,b,c,d,e,f,g
|
||||||
|
Volume int `json:"volume" db:"volume"` //音量,1-5 ,对应打印机2-10
|
||||||
|
FlowFlag int `json:"flowFlag" db:"flow_flag"` //是否超流量了,1表示超了
|
||||||
|
OfflineCount int `json:"offlineCount" db:"offline_count"` //掉线次数
|
||||||
|
UserId string `json:"user_id" db:"user_id"` //打印机所属用户
|
||||||
|
}
|
||||||
|
|
||||||
|
type SystemTemp struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
LastOperator string `json:"last_operator" db:"last_operator"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
|
||||||
|
TempName string `json:"temp_name" db:"temp_name"` // 模板名称
|
||||||
|
TempRank string `orm:"type(text)" json:"temp_rank" db:"temp_rank"` // 模板顺序
|
||||||
|
Temp string `orm:"type(text)" json:"temp" db:"temp"` // 模板
|
||||||
|
UserId string `json:"user_id" db:"user_id"` // 所属用户
|
||||||
|
TempType string `json:"temp_type" db:"temp_type"` // 模板类型
|
||||||
|
TempSize string `json:"temp_size" db:"temp_size"` // 模板尺寸 big/medium/small
|
||||||
|
PrintSn string `json:"print_sn" db:"print_sn"` // 模板所属打印机
|
||||||
|
IsUse int `json:"is_use" db:"is_use"` // 默认使用 1-使用/2-不使用
|
||||||
|
Properties string `orm:"type(text)" json:"properties" db:"properties"` // 模板字段属性
|
||||||
|
}
|
||||||
|
|
||||||
|
type Apps struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
LastOperator string `json:"last_operator" db:"last_operator"`
|
||||||
|
DeletedAt time.Time `json:"deleted_at" db:"deleted_at"`
|
||||||
|
UserID string `orm:"column(user_id)" json:"user_id" db:"user_id"` //属于哪个账号的
|
||||||
|
Name string `json:"name"` //应用名称
|
||||||
|
Type int `json:"type"` //应用类型
|
||||||
|
AppKey string `json:"app_key" db:"app_key"` //Key
|
||||||
|
Status int `json:"status"` //状态
|
||||||
|
Mobile string `json:"mobile"` //手机号
|
||||||
|
}
|
||||||
|
|
||||||
|
type MenuDetail struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
LastOperator string `json:"last_operator" db:"last_operator"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
|
||||||
|
MenuID int `orm:"column(menu_id)" json:"menu_id" db:"menu_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
URL string `orm:"column(url)" json:"url" db:"url"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
PublicParam string `json:"public_param" db:"public_param"`
|
||||||
|
PrivateParam string `json:"private_param" db:"private_param"`
|
||||||
|
CallParam string `json:"call_param" db:"call_param"`
|
||||||
|
ReturnParam string `json:"return_param" db:"return_param"`
|
||||||
|
ReturnEX string `orm:"column(return_ex)" json:"return_ex" db:"return_ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//流量支出
|
||||||
|
type SimFlowExpend struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
LastOperator string `json:"last_operator" db:"last_operator"`
|
||||||
|
IccID string `orm:"column(icc_id)" json:"icc_id" db:"icc_id"` //sim卡iccid
|
||||||
|
Flow float64 `json:"flow"` //流量数
|
||||||
|
FlowUnit string `json:"flow_unit" db:"flow_unit"` //流量单位
|
||||||
|
}
|
||||||
|
|
||||||
|
//流量划入
|
||||||
|
type SimFlowIncome struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
LastOperator string `json:"last_operator" db:"last_operator"`
|
||||||
|
IccID string `orm:"column(icc_id)" json:"icc_id" db:"icc_id"` //sim卡iccid
|
||||||
|
Flow float64 `json:"flow"` //流量数
|
||||||
|
FlowUnit string `json:"flow_unit" db:"flow_unit"` //流量单位
|
||||||
|
IncomeType int `json:"income_type" db:"income_type"` //1 表示系统每月自动划转,2 表示商户自己冲的
|
||||||
|
OrderID string `orm:"column(order_id)" json:"order_id" db:"order_id"` //订单号
|
||||||
|
}
|
||||||
|
|
||||||
|
type PayOrder struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
OrderID string `orm:"column(order_id)" json:"order_id" db:"order_id"` //订单号
|
||||||
|
UserID string `orm:"column(user_id)" json:"user_id" db:"user_id"` //用户ID
|
||||||
|
OrderType string `json:"order_type" db:"order_type"` //订单类型,流量充值等
|
||||||
|
Origin string `json:"origin"` //订单来源,小程序,开放后台
|
||||||
|
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
||||||
|
PayPrice int64 `json:"pay_price" db:"pay_price"` //支付金额
|
||||||
|
TransactionID string `orm:"column(transaction_id)" json:"transaction_id" db:"transaction_id"` // 支付成功后,支付方生成的事务ID
|
||||||
|
PayFinishedAt *time.Time `json:"pay_finished_at" db:"pay_finished_at"`
|
||||||
|
PrepayID string `orm:"column(prepay_id)" json:"prepay_id" db:"prepay_id"` // 下单后,支付前,支付方生成的事务ID
|
||||||
|
OriginalData *string `json:"original_data" db:"original_data"`
|
||||||
|
Comment string `json:"comment"` //备注
|
||||||
|
ThingID string `orm:"column(thing_id)" json:"thing_id" db:"thing_id"` //订单充值项目ID
|
||||||
|
TypeID string `orm:"column(type_id)" json:"type_id" db:"type_id"` //类型ID,充流量就是套餐对应的id
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderPay struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `orm:"type(datetime)" json:"created_at" db:"created_at"` // 创建时间
|
||||||
|
UpdatedAt time.Time `orm:"type(datetime)" json:"updated_at" db:"updated_at"` // 更新时间
|
||||||
|
PayOrderID string `orm:"column(pay_order_id);size(48)" json:"pay_order_id" db:"pay_order_id"` // 京西支付定单号
|
||||||
|
PayType int `orm:"type(int);size(2)" json:"pay_type" db:"pay_type"` // 支付类型[1-微信,2-通联,3-抖音]
|
||||||
|
VendorPayType string `orm:"size(48)" json:"vendorPayType"` //
|
||||||
|
VendorOrderID string `orm:"column(vendor_order_id);size(48);index" json:"vendor_order_id" db:"vendor_order_id"` // 支付对应的购物订单号
|
||||||
|
PrintNo string `orm:"column(print_no);size(48);index" json:"print_no" db:"print_no"` // 充值打印机编号
|
||||||
|
Status int `orm:"type(int);size(2)" json:"status" json:"status" db:"status"` // 订单支付状态
|
||||||
|
PayCreatedAt time.Time `orm:"type(datetime);index" json:"pay_created_at" db:"pay_created_at"` // 下单时间
|
||||||
|
PayFinishedAt time.Time `orm:"type(datetime)" json:"pay_finished_at" db:"pay_finished_at"` // 支付完成时间
|
||||||
|
TotalFee int `orm:"type(int);size(11)" json:"total_fee" db:"total_fee"` // 支付金额
|
||||||
|
PrepayID string `orm:"column(prepay_id);index;size(48)" json:"prepay_id" db:"prepay_id"` // 下单后,支付前,支付方生成的事务ID
|
||||||
|
TransactionID string `orm:"column(transaction_id);index;size(48)" json:"transaction_id" db:"transaction_id"` // 支付成功后,支付方生成的事务ID
|
||||||
|
OriginalData string `orm:"type(text)" json:"-"` // 返回消息
|
||||||
|
VendorID int `orm:"column(vendor_id)" json:"vendor_id" db:"vendor_id"` // 购物订单所属厂商代码(当前只有京西)
|
||||||
|
CodeURL string `orm:"column(code_url);size(3200)" json:"codeURL"` //
|
||||||
|
}
|
||||||
26
business/model/print_Edition.go
Normal file
26
business/model/print_Edition.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// PrintEdition 版本控制
|
||||||
|
type PrintEdition struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `orm:"type(datetime)" json:"created_at" db:"created_at"` // 创建时间
|
||||||
|
UpdatedAt time.Time `orm:"type(datetime)" json:"updated_at" db:"updated_at"` // 更新时间
|
||||||
|
EditionNo string `orm:"type(varchar);size(64)" json:"edition_no" db:"edition_no"` // 版本号
|
||||||
|
EditionMsg string `orm:"type(text)" json:"edition_msg" db:"edition_msg"` // 更新说明
|
||||||
|
IsHotBuild int `orm:"type(tinyint)" json:"is_hot_build" db:"is_hot_build"` // 是否热更新
|
||||||
|
IsForce int `orm:"type(tinyint)" json:"is_force" db:"is_force"` // 是否强制更新
|
||||||
|
APKUrl string `orm:"column(apk_url);type(varchar);size(255)" json:"apk_url" db:"apk_url"` // apk下载地址
|
||||||
|
HotUrl string `orm:"type(varchar);size(255)" json:"hot_url" db:"hot_url"` // 热更下载地址
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintNotice 包含广告和通知消息
|
||||||
|
type PrintNotice struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `orm:"type(datetime)" json:"created_at" db:"created_at"` // 创建时间
|
||||||
|
UpdatedAt time.Time `orm:"type(datetime)" json:"updated_at" db:"updated_at"` // 更新时间
|
||||||
|
NoticeType int `orm:"type(int)" json:"notice_type" db:"notice_type"` // 类型(1-广告/2-通知)
|
||||||
|
Msg string `orm:"type(text)" json:"msg" db:"msg"` // 内容(广告就是图片,通知消息就是文字)
|
||||||
|
Link string `orm:"type(varchar);size(255)" json:"link" db:"link"` // 跳转地址
|
||||||
|
}
|
||||||
10
business/model/print_activation.go
Normal file
10
business/model/print_activation.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// PrintActivation 打印机激活记录
|
||||||
|
type PrintActivation struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
|
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
|
||||||
|
}
|
||||||
13
business/model/print_bill.go
Normal file
13
business/model/print_bill.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// PrintBill 打印机账户
|
||||||
|
type PrintBill struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
|
||||||
|
PrintBalance int64 `orm:"type(int);size(16)" json:"print_balance" db:"print_balance"` // 账户余额
|
||||||
|
UserId string `orm:"type(varchar);size(125)" json:"user_id" db:"user_id"` // 打印机所属用户
|
||||||
|
}
|
||||||
28
business/model/print_bill_record.go
Normal file
28
business/model/print_bill_record.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// PrintBillRecord 打印机充值/小费记录
|
||||||
|
type PrintBillRecord struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
|
||||||
|
PayType int `orm:"type(int);size(2)" json:"pay_type" db:"pay_type"` // 支付类型[1-充值/2-支出]
|
||||||
|
PayMoney int `orm:"type(int);size(10)" json:"pay_money" db:"pay_money"` // 金额
|
||||||
|
OrderId string `orm:"type(varchar);size(64);index" json:"order_id" db:"order_id"` // 订单号
|
||||||
|
UserId string `orm:"type(varchar);size(125)" json:"user_id" db:"user_id"` // 打印机所属用户
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrintBindStore struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `orm:"type(datetime)" json:"created_at" db:"created_at"` // 创建时间
|
||||||
|
UpdatedAt time.Time `orm:"type(datetime)" json:"updated_at" db:"updated_at"` // 更新时间
|
||||||
|
StoreID int64 `orm:"column(store_id);type(int);size(11)" json:"store_id" db:"store_id"` // 门店id(为京西创建门店id)唯一
|
||||||
|
StoreName string `orm:"type(varchar);size(255)" json:"store_name" db:"store_name"` // 门店名称
|
||||||
|
StoreVendor int `orm:"type(int);size(2)" json:"store_vendor" db:"store_vendor"` // 门店平台
|
||||||
|
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
|
||||||
|
UserId string `orm:"type(varchar);size(125)" json:"user_id" db:"user_id"` // 打印机所属用户
|
||||||
|
StoreStatus int `orm:"type(int);size(2)" json:"store_status" db:"store_status"` // 门店状态
|
||||||
|
BindStatus int `orm:"type(int);size(2)" json:"bind_status" db:"bind_status"` // 绑定状态
|
||||||
|
}
|
||||||
96
business/model/print_open.go
Normal file
96
business/model/print_open.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
const (
|
||||||
|
PrinterStatusOnlineWithoutPaper = 2 //在线缺纸
|
||||||
|
PrinterStatusOnline = 1 //在线正常
|
||||||
|
PrinterStatusOffline = -1 //离线
|
||||||
|
PrinterStatusNoFlow = -2 //当月流量超30m了
|
||||||
|
|
||||||
|
PrintMsgAlreadySend = 2 //已经发出打印消息
|
||||||
|
PrintMsgSuccess = 1 //打印成功
|
||||||
|
PrintMsgWait = 0 //待打印
|
||||||
|
PrintMsgFail = -1 //打印失败(打印机报出)
|
||||||
|
PrintMsgErr = -2 //京西报出
|
||||||
|
PrintMsgAll = -9
|
||||||
|
)
|
||||||
|
|
||||||
|
type AddPrinterParam struct {
|
||||||
|
PrintNo string `json:"print_no"` //打印机编号
|
||||||
|
Name string `json:"name"` //打印机备注名
|
||||||
|
SIM string `json:"sim"` //sim卡号-电话号码,接受验证的电话
|
||||||
|
StoreId int64 `json:"store_id"` // 门店id
|
||||||
|
}
|
||||||
|
|
||||||
|
//type Printer struct {
|
||||||
|
// ModelIDCULD
|
||||||
|
//
|
||||||
|
// AppID int `orm:"column(app_id)" json:"app_id" db:"app_id"` //应用编号
|
||||||
|
// PrintNo string `json:"print_no" db:"print_no"` //打印机编号
|
||||||
|
// PrintKey string `json:"print_key" db:"print_key"` //打印机识别码
|
||||||
|
// Name string `json:"name" db:"name"` //打印机备注名
|
||||||
|
// Status int `json:"status" db:"status"` //打印机状态
|
||||||
|
// IsOnline int `json:"is_online" db:"is_online"` //1在线,0离线
|
||||||
|
// IccID string `orm:"column(icc_id)" json:"IccID" db:"icc_id"` //sim卡号
|
||||||
|
// Sound string `json:"sound" db:"sound"` //声音类型 sounda ,b,c,d,e,f,g
|
||||||
|
// Volume int `json:"volume" db:"volume"` //音量,1-5 ,对应打印机2-10
|
||||||
|
// FlowFlag int `json:"flowFlag" db:"flow_flag"` //是否超流量了,1表示超了
|
||||||
|
// OfflineCount int `json:"offlineCount" db:"offline_count"` //掉线次数
|
||||||
|
// UserId string `orm:"column(user_id)" json:"user_id" db:"user_id"` //用户id
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (v *Printer) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"PrintNo"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//type PrintMsg struct {
|
||||||
|
// ModelIDCULD
|
||||||
|
//
|
||||||
|
// MsgID string `orm:"column(msg_id)" json:"msg_id" db:"msg_id"` //消息ID
|
||||||
|
// PrintNo string `json:"print_no" db:"print_no"` //打印机编号
|
||||||
|
// OrderNo string `json:"order_no" db:"order_no"` //订单序号
|
||||||
|
// Content string `orm:"type(text)" json:"content" db:"content"` //订单内容
|
||||||
|
// Status int `json:"status" db:"status"` //打印状态
|
||||||
|
// Comment string `json:"comment" db:"comment"` //失败原因
|
||||||
|
// ContentEncryption string `orm:"type(text)" json:"content_encryption" db:"content_encryption"` //订单类容进制文件
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (v *PrintMsg) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"PrintNo"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//流量支出
|
||||||
|
//type SimFlowExpend struct {
|
||||||
|
// ModelIDCUL
|
||||||
|
//
|
||||||
|
// IccID string `orm:"column(icc_id)" json:"iccID" db:"icc_id"` //sim卡iccid
|
||||||
|
// Flow float64 `json:"flow" db:"flow"` //流量数
|
||||||
|
// FlowUnit string `json:"flowUnit" db:"flow_unit"` //流量单位
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (v *SimFlowExpend) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"IccID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//流量划入
|
||||||
|
//type SimFlowIncome struct {
|
||||||
|
// ModelIDCUL
|
||||||
|
//
|
||||||
|
// IccID string `orm:"column(icc_id)" json:"iccID" db:"icc_id"` //sim卡iccid
|
||||||
|
// Flow float64 `json:"flow" db:"flow"` //流量数
|
||||||
|
// FlowUnit string `json:"flowUnit" db:"flow_unit"` //流量单位
|
||||||
|
// IncomeType int `json:"incomeType" db:"income_type"` //1 表示系统每月自动划转,2 表示商户自己冲的
|
||||||
|
// OrderID string `orm:"column(order_id)" json:"order_id" db:"order_id"` //订单号
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (v *SimFlowIncome) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"IccID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
118
business/model/print_setting.go
Normal file
118
business/model/print_setting.go
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PrintSetting 打印机设置
|
||||||
|
type PrintSetting struct {
|
||||||
|
ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
DeletedAt time.Time `json:"deleted_at" db:"deleted_at"`
|
||||||
|
PrintNo string `orm:"type(varchar);size(32)" json:"print_no" db:"print_no"` // 打印机编号
|
||||||
|
CallNameSetting int `orm:"type(int);size(4);default(64)" json:"call_name_setting" db:"call_name_setting"` // 称谓设置 [64-默认老板]
|
||||||
|
BusinessOffLineVoice int `orm:"type(tinyint);size(2);default(1)" json:"business_off_line_voice" db:"business_off_line_voice"` // 店铺离线语音[1打开]
|
||||||
|
BalanceNotEnoughVoice int `orm:"type(tinyint);size(2);default(1)" json:"balance_not_enough_voice" db:"balance_not_enough_voice"` // 余额不足语音提示[1打开]
|
||||||
|
EveryDayGreetVoice int `orm:"type(tinyint);size(2);default(1)" json:"every_day_greet_voice" db:"every_day_greet_voice"` // 每日招呼语音[1打开]
|
||||||
|
BusinessPrintNum int `orm:"type(int);size(4);default(1)" json:"business_print_num" db:"business_print_num"` // 商家侧订单打印次数
|
||||||
|
CustomerPrintNum int `orm:"type(int);size(4);default(1)" json:"customer_print_num" db:"customer_print_num"` // 用户侧订单打印次数
|
||||||
|
VoiceSetting string `orm:"type(varchar);size(1024)" json:"voice_setting" db:"voice_setting"` // 语音设置
|
||||||
|
PrintSetting string `orm:"type(varchar);size(1024)" json:"print_setting" db:"print_setting"` // 打印设置
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *PrintSetting) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"PrintNo"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *PrintSetting) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"CreatedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrintSettingObj struct {
|
||||||
|
ID int `json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
DeletedAt time.Time `json:"deleted_at" db:"deleted_at"`
|
||||||
|
PrintNo string `json:"print_no" db:"print_no"` // 打印机编号
|
||||||
|
CallNameSetting int `json:"call_name_setting" db:"call_name_setting"` // 称谓设置 [64-默认老板]
|
||||||
|
|
||||||
|
BusinessOffLineVoice int `json:"business_off_line_voice" db:"business_off_line_voice"` // 店铺离线语音[1打开]
|
||||||
|
BalanceNotEnoughVoice int `json:"balance_not_enough_voice" db:"balance_not_enough_voice"` // 余额不足语音提示[1打开]
|
||||||
|
EveryDayGreetVoice int `json:"every_day_greet_voice" db:"every_day_greet_voice"` // 每日招呼语音[1打开]
|
||||||
|
BusinessPrintNum int `json:"business_print_num" db:"business_print_num"` // 商家侧订单打印次数
|
||||||
|
CustomerPrintNum int `json:"customer_print_num" db:"customer_print_num"` // 用户侧订单打印次数
|
||||||
|
|
||||||
|
VoiceSetting *VoiceSettingDetail `json:"voice_setting" db:"voice_setting"` // 语音设置
|
||||||
|
PrintSetting *PrintSettingDetail `json:"print_setting" db:"print_setting"` // 打印设置
|
||||||
|
}
|
||||||
|
|
||||||
|
// VoiceSettingDetail 语音设置
|
||||||
|
type VoiceSettingDetail struct {
|
||||||
|
WaitOrderVoice int `json:"wait_order_voice"` // 待接单语音[1打开]
|
||||||
|
RiderTakeOrderVoice int `json:"rider_take_order_voice"` // 骑手接单语音[1打开]
|
||||||
|
ApplyUserOrderCancelVoice int `json:"apply_user_order_cancel_voice"` // 用户申请取消订单语音提示[1打开]
|
||||||
|
ApplyRefundOrderVoice int `json:"apply_refund_order_voice"` // 用户申请退款提示语音[1打开]
|
||||||
|
RefundGoodsVoice int `json:"refund_goods_voice"` // 订单已经取消语音[1打开]
|
||||||
|
CustomerRejectionVoice int `json:"customer_rejection_voice"` // 客户拒收语音[1打开]
|
||||||
|
CusterRefundVoice int `json:"custer_refund_voice"` // 客服(平台)退款语音[1打开]
|
||||||
|
LoseAuthorization int `json:"lose_authorization"` // 失去授权语音提示[1打开]
|
||||||
|
ApplyRefundGoodsVoice int `json:"apply_refund_goods_voice"` // 用户申请退货提示语音[1打开]
|
||||||
|
SuccessGoodsVoice int `json:"success_goods_voice"` // 订单完成语音[1打开](没语音)
|
||||||
|
ReminderVoice int `json:"reminder_voice"` // 客户催单语音[1打开]
|
||||||
|
ConsultingPrint int `json:"consulting_print"` // 客户进店咨询打印[1打开](暂时没有)
|
||||||
|
ConfirmGoodsVoice int `json:"confirm_goods_voice"` // 确认接单语音[1打开](可以不做)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintSettingDetail 打印设置
|
||||||
|
type PrintSettingDetail struct {
|
||||||
|
UserOrderCancel int `json:"user_order_cancel"` // 用户取消订单打印[1打开]
|
||||||
|
RiderTakeOrder int `json:"rider_take_order"` // 骑手接单打印[1打开]
|
||||||
|
CusterRefundPrint int `json:"custer_refund_print"` // 客服退款打印[1打开]
|
||||||
|
WaitOrderPrint int `json:"wait_order_print"` // 待接单打印[1打开]
|
||||||
|
ApplyUserCancelOrder int `json:"apply_user_cancel_order"` // 用户申请取消订单打印[1打开]
|
||||||
|
ApplyUserRefund int `json:"apply_user_refund"` // 申请部分退款打印[1打开]
|
||||||
|
CustomerRejectionPrint int `json:"customer_rejection_print"` // 客户拒收打印[1打开]
|
||||||
|
OrderCancelSuccess int `json:"order_cancel_success"` // 取消成功打印[1打开]
|
||||||
|
BusinessOrderCancel int `json:"business_order_cancel"` // 商家取消打印[1打开]
|
||||||
|
RefundOrder int `json:"refund_order"` // 订单退款打印[1打开]
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnMarshalString2Json 将字符串设置转换为对象设置
|
||||||
|
func UnMarshalString2Json(param *PrintSetting) (*PrintSettingObj, error) {
|
||||||
|
var (
|
||||||
|
printSetting = &PrintSettingDetail{}
|
||||||
|
voiceSetting = &VoiceSettingDetail{}
|
||||||
|
)
|
||||||
|
|
||||||
|
result := &PrintSettingObj{
|
||||||
|
ID: param.ID,
|
||||||
|
CreatedAt: param.CreatedAt,
|
||||||
|
UpdatedAt: param.UpdatedAt,
|
||||||
|
DeletedAt: param.DeletedAt,
|
||||||
|
PrintNo: param.PrintNo,
|
||||||
|
CallNameSetting: param.CallNameSetting,
|
||||||
|
BusinessOffLineVoice: param.BusinessOffLineVoice,
|
||||||
|
BalanceNotEnoughVoice: param.BalanceNotEnoughVoice,
|
||||||
|
EveryDayGreetVoice: param.EveryDayGreetVoice,
|
||||||
|
BusinessPrintNum: param.BusinessPrintNum,
|
||||||
|
CustomerPrintNum: param.CustomerPrintNum,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := json.Unmarshal([]byte(param.VoiceSetting), voiceSetting); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result.VoiceSetting = voiceSetting
|
||||||
|
|
||||||
|
if err := json.Unmarshal([]byte(param.PrintSetting), printSetting); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result.PrintSetting = printSetting
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
50
business/model/print_temp.go
Normal file
50
business/model/print_temp.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
//
|
||||||
|
//type SystemTemp struct {
|
||||||
|
// ID int `orm:"column(id)" json:"id" db:"id"`
|
||||||
|
// CreatedAt *time.Time `json:"created_at" db:"created_at"`
|
||||||
|
// UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
// LastOperator string `json:"last_operator" db:"last_operator"`
|
||||||
|
// DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
|
||||||
|
// TempName string `json:"temp_name" db:"temp_name"` // 模板名称
|
||||||
|
// TempRank string `orm:"type(text)" json:"temp_rank" db:"temp_rank"` // 模板顺序
|
||||||
|
// Temp string `orm:"type(text)" json:"temp" db:"temp"` // 模板
|
||||||
|
// UserId string `json:"user_id" db:"user_id"` // 所属用户
|
||||||
|
// TempType string `json:"temp_type" db:"temp_type"` // 模板类型
|
||||||
|
// TempSize string `json:"temp_size" db:"temp_size"` // 模板尺寸 big/medium/small
|
||||||
|
// PrintSn string `json:"print_sn" db:"print_sn"` // 模板所属打印机
|
||||||
|
// IsUse int `json:"is_use" db:"is_use"` // 默认使用 1-使用/2-不使用
|
||||||
|
// Properties string `orm:"type(text)" json:"properties" db:"properties"` // 模板字段属性
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////func (v *SystemTemp) TableUnique() [][]string {
|
||||||
|
//// return [][]string{
|
||||||
|
//// []string{"PrintNo"},
|
||||||
|
//// }
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//func (v *SystemTemp) TableIndex() [][]string {
|
||||||
|
// return [][]string{
|
||||||
|
// []string{"UserId", "TempType", "TempSize"},
|
||||||
|
// []string{"PrintSn"},
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
const (
|
||||||
|
TempTypeMerchantUser = `user_store` // 商户自定义模板-商户看
|
||||||
|
TempTypeConsumerUser = `user_consumer` // 商户自定义模板-消费用户看
|
||||||
|
TempTypeMerchant = `sys_store` // 系统模板-商户看
|
||||||
|
TempTypeConsumer = `sys_consumer` // 系统模板-消费用户看
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SystemTempSizeBig = "big"
|
||||||
|
SystemTempSizeSmall = "small"
|
||||||
|
SystemTempSizeMedium = "medium"
|
||||||
|
)
|
||||||
|
const (
|
||||||
|
SettingOpen = 1 // 开启
|
||||||
|
SettingClose = -1 // 关闭
|
||||||
|
)
|
||||||
149
business/model/print_temp_config.go
Normal file
149
business/model/print_temp_config.go
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
//
|
||||||
|
//var TempTag map[string]string
|
||||||
|
//
|
||||||
|
//func init() {
|
||||||
|
// TempTag = make(map[string]string, 26)
|
||||||
|
// TempTag["title"] = Title
|
||||||
|
// TempTag["sound"] = Sound
|
||||||
|
// TempTag["eBailOrderNo"] = EBailOrderNo
|
||||||
|
// TempTag["payOrderTime"] = PayOrderTime
|
||||||
|
// TempTag["trySendTime"] = TrySendTime
|
||||||
|
// TempTag["orderNo"] = OrderNo
|
||||||
|
// TempTag["businessType"] = BusinessType
|
||||||
|
// TempTag["vendorName"] = VendorName
|
||||||
|
// TempTag["eBaiCode"] = EBaiCode
|
||||||
|
// TempTag["qRCOrder"] = QRCOrder
|
||||||
|
// TempTag["eBaiVendorName"] = EBaiVendorName
|
||||||
|
// TempTag["eBaiOrderNo"] = EBaiOrderNo
|
||||||
|
// TempTag["consigneeName"] = ConsigneeName
|
||||||
|
// TempTag["consigneeMobile"] = ConsigneeMobile
|
||||||
|
// TempTag["consigneeAddress"] = ConsigneeAddress
|
||||||
|
// TempTag["buyerComment"] = BuyerComment
|
||||||
|
// TempTag["goodsListDetail"] = GoodsListDetail
|
||||||
|
// TempTag["skuName"] = SkuName
|
||||||
|
// TempTag["skuNumber"] = SkuNumber
|
||||||
|
// TempTag["skuPrice"] = SkuPrice
|
||||||
|
// TempTag["skuAllPrice"] = SkuAllPrice
|
||||||
|
// TempTag["allSkuTypeCount"] = AllSkuTypeCount
|
||||||
|
// TempTag["allSkuCount"] = AllSkuCount
|
||||||
|
// TempTag["storeName"] = StoreName
|
||||||
|
// TempTag["storeTel"] = StoreTel
|
||||||
|
// TempTag["officialName"] = OfficialName
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//const (
|
||||||
|
// //SystemTempKey 公共参数 EBaiOrderNo= vendorName EBaiVendorName = vendorOrderNo
|
||||||
|
// SystemTempKey = "title,sound,eBailOrderNo,payOrderTime,trySendTime,orderNo,businessType,vendorName,eBaiCode,qRCOrder,eBaiVendorName,eBaiOrderNo,consigneeName," +
|
||||||
|
// "consigneeMobile,consigneeAddress,buyerComment,goodsListDetail,skuName,skuNumber,skuPrice,skuAllPrice,skuUpc,allSkuTypeCount,allSkuCount,storeName,storeTel,officialName"
|
||||||
|
// SystemTempValue = "{" +
|
||||||
|
// "title:" + Title + "," +
|
||||||
|
// "sound:" + Sound + "," +
|
||||||
|
// "eBailOrderNo:" + EBailOrderNo + "," +
|
||||||
|
// "payOrderTime:" + PayOrderTime + "," +
|
||||||
|
// "trySendTime:" + TrySendTime + "," +
|
||||||
|
// "orderNo:" + OrderNo + "," +
|
||||||
|
// "businessType:" + BusinessType + "," +
|
||||||
|
// "vendorName:" + VendorName + "," +
|
||||||
|
// "eBaiCode:" + EBaiCode + "," +
|
||||||
|
// "qRCOrder:" + QRCOrder + "," +
|
||||||
|
// "eBaiVendorName:" + EBaiVendorName + "," +
|
||||||
|
// "eBaiOrderNo:" + EBaiOrderNo + "," +
|
||||||
|
// "consigneeName:" + ConsigneeName + "," +
|
||||||
|
// "consigneeMobile:" + ConsigneeMobile + "," +
|
||||||
|
// "consigneeAddress:" + ConsigneeAddress + "," +
|
||||||
|
// "buyerComment:" + BuyerComment + "," +
|
||||||
|
// "goodsListDetail:" + GoodsListDetail + "," +
|
||||||
|
// "skuName:" + SkuName + "," +
|
||||||
|
// "skuNumber:" + SkuNumber + "," +
|
||||||
|
// "skuPrice:" + SkuPrice + "," +
|
||||||
|
// "skuAllPrice:" + SkuAllPrice + "," +
|
||||||
|
// "skuUpc:" + SkuUpc + "," +
|
||||||
|
// "allSkuTypeCount:" + AllSkuTypeCount + "," +
|
||||||
|
// "allSkuCount:" + AllSkuCount + "," +
|
||||||
|
// "storeName:" + StoreName + "," +
|
||||||
|
// "storeTel:" + StoreTel + "," +
|
||||||
|
// "officialName:" + OfficialName +
|
||||||
|
// "}"
|
||||||
|
//
|
||||||
|
// Title = `<center>手机买菜上京西</center><br>
|
||||||
|
// <center>极速到家送惊喜</center><br>
|
||||||
|
// --------------------------------<br>`
|
||||||
|
//
|
||||||
|
// Sound = `<br><sound>%d</sound><br>`
|
||||||
|
// EBailOrderNo = `<center><b>%s</b></center><br><br>`
|
||||||
|
// PayOrderTime = ` <b>下单时间: %s</b><br>`
|
||||||
|
// TrySendTime = ` <b>预计送达: %s</b><br>`
|
||||||
|
// OrderNo = ` <b>订单编号: %s</b><br>`
|
||||||
|
// BusinessType = `<center><b>预订单</b></center><br>`
|
||||||
|
//
|
||||||
|
// VendorName = `<br><b>%s`
|
||||||
|
// EBaiCode = `#%s</b><br>`
|
||||||
|
//
|
||||||
|
// QRCOrder = `<qrc>%s</qrc><br>`
|
||||||
|
// EBaiVendorName = `<b>%s:`
|
||||||
|
// EBaiOrderNo = `%s</b><br><br>`
|
||||||
|
// ConsigneeName = ` <b>客户: %s<br>`
|
||||||
|
// ConsigneeMobile = ` <b>电话: %s<br>`
|
||||||
|
// ConsigneeAddress = ` <b>地址: %s<br><br>`
|
||||||
|
//
|
||||||
|
// BuyerComment = ` <b>客户备注:</b><br><b>%s</b><br><br>`
|
||||||
|
// GoodsListDetail = `商品明细:<br>
|
||||||
|
// 品名 数量 单价 小计<br>
|
||||||
|
// --------------------------------<br>`
|
||||||
|
//
|
||||||
|
// SkuName = `<b>%s</b><br>`
|
||||||
|
// SkuNumber = `<b>x%s</b>`
|
||||||
|
// SkuPrice = ` <b>¥%s</b>`
|
||||||
|
// SkuAllPrice = ` <b>¥%s</b><br>`
|
||||||
|
// SkuUpc = `upc码: %s\n`
|
||||||
|
//
|
||||||
|
// AllSkuTypeCount = `<br><br><b>共%s种,`
|
||||||
|
// AllSkuCount = `%s件商品</b><br>--------------------------------<br>`
|
||||||
|
//
|
||||||
|
// StoreName = `<center><b>商品质量问题请联系:</b></center><br><center><b>%s:`
|
||||||
|
// StoreTel = `%s</b></center><br><br>更多信息请关注官方微信: `
|
||||||
|
//
|
||||||
|
// OfficialName = `<b>%s</b><br><br><br>
|
||||||
|
// --------------------------------<br>
|
||||||
|
// --------------------------------<br><br>`
|
||||||
|
//)
|
||||||
|
|
||||||
|
type SkuListPrintOrder struct {
|
||||||
|
SkuName string `json:"skuName"` // 商品名称
|
||||||
|
SkuCount string `json:"skuCount"` // 商品数量
|
||||||
|
SalePrice string `json:"salePrice"` // 单价
|
||||||
|
TotalCountPrice string `json:"totalCountPrice"` // 总价
|
||||||
|
Upc string `json:"upc"` // 条形码
|
||||||
|
}
|
||||||
|
|
||||||
|
type JXPrintData struct {
|
||||||
|
EBailOrderNo string `json:"e_bail_order_no"` // 饿百取货码(品牌名称)
|
||||||
|
BusinessType string `json:"business_type"` // 是否为预定单 2-是/1-否
|
||||||
|
PayOrderTime string `json:"pay_order_time"` // 下单时间
|
||||||
|
TrySendTime string `json:"try_send_time"` // 预计送达时间
|
||||||
|
OrderNo string `json:"order_no"` // 订单编号
|
||||||
|
VendorName string `json:"vendor_name"` // 订单来源平台名称
|
||||||
|
VendorID string `json:"vendor_id"` // 订单来源平台Id
|
||||||
|
VendorOrderNo string `json:"vendor_order_no"` // 订单序号
|
||||||
|
EBaiCode string `json:"e_bai_code"` // 饿百取货码
|
||||||
|
QRCOrder string `json:"qrc_order"` // 订单二维码单号,还是订单Id
|
||||||
|
ConsigneeName string `json:"consignee_name"` // 客户名称
|
||||||
|
ConsigneeMobile string `json:"consignee_mobile"` // 客户电话
|
||||||
|
ConsigneeAddress string `json:"consignee_address"` // 客户地址
|
||||||
|
BuyerComment string `json:"buyer_comment"` // 客户备注
|
||||||
|
SkuList []*SkuListPrintOrder `json:"sku_list"` // 商品列表
|
||||||
|
SkuName string `json:"sku_name"` // 商品名称
|
||||||
|
SkuCount string `json:"sku_count"` // 商品件数
|
||||||
|
SkuOnePrice string `json:"sku_one_price"` // 商品单价
|
||||||
|
SkuAllPrice string `json:"sku_all_price"` // 商品总价 = 商品件数 x 商品件数
|
||||||
|
AllSkuTypeCount string `json:"all_sku_type_count"` // 商品种类
|
||||||
|
AllSkuCount string `json:"all_sku_count"` // 商品总数量
|
||||||
|
UserPayMoney string `json:"user_pay_money"` // 用户支付
|
||||||
|
StoreName string `json:"store_name"` // 门店名称
|
||||||
|
StoreTel string `json:"store_tel"` // 门店电话
|
||||||
|
OfficialName string `json:"official_name"` // 官方名称
|
||||||
|
BigFont string `json:"big_font"` // 是否为大字体
|
||||||
|
PrintNumber string `json:"print_number"` // 打印次数
|
||||||
|
}
|
||||||
159
business/model/print_temp_voice.go
Normal file
159
business/model/print_temp_voice.go
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
var NumberVoiceMap map[string]int
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
NumberVoiceMap = map[string]int{
|
||||||
|
"0": ZeroVoice,
|
||||||
|
"1": OneVoice,
|
||||||
|
"2": TwoVoice,
|
||||||
|
"3": ThreeVoice,
|
||||||
|
"4": FourVoice,
|
||||||
|
"5": FiveVoice,
|
||||||
|
"6": SixVoice,
|
||||||
|
"7": SevenVoice,
|
||||||
|
"8": EightVoice,
|
||||||
|
"9": NineVoice,
|
||||||
|
"10": TenVoice,
|
||||||
|
"20": TwentyVoice,
|
||||||
|
"30": ThirtyVoice,
|
||||||
|
"40": FortyVoice,
|
||||||
|
"50": FiftyVoice,
|
||||||
|
"60": SixtyVoice,
|
||||||
|
"70": SeventyVoice,
|
||||||
|
"80": EightyVoice,
|
||||||
|
"90": NinetyVoice,
|
||||||
|
"100": OneHundredVoice,
|
||||||
|
"200": TwoHundredVoice,
|
||||||
|
"300": ThereHundredVoice,
|
||||||
|
"400": FourHundredVoice,
|
||||||
|
"500": FiveHundredVoice,
|
||||||
|
"600": SixHundredVoice,
|
||||||
|
"700": SeventyHundredVoice,
|
||||||
|
"800": EightHundredVoice,
|
||||||
|
"900": NineHundredVoice,
|
||||||
|
"1000": OneThousandVoice,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 语音常量
|
||||||
|
const (
|
||||||
|
WeComeJXPrintVoice = 1 //. 欢迎使用京西云打印机.mp3
|
||||||
|
NetConnSuccessVoice = 2 //. 网络连接成功.mp3
|
||||||
|
NetConnFailVoice = 3 //. 网络连接失败和心跳失败.mp3
|
||||||
|
PrintLostPaperVoice = 4 //. 打印机缺纸或装纸错误.mp3
|
||||||
|
WFILPasswordErrVoice = 5 //. WIFI密码错误.mp3
|
||||||
|
NewOrderVoice = 6 //. 您来新订单了.mp3
|
||||||
|
WaitOrderVoice = 7 //. 您有新订单未处理.mp3
|
||||||
|
WaitPickUpOrderVoice = 8 //. 您有订单未拣货.mp3
|
||||||
|
RiderGetOrderVoice = 9 //. 骑手接单了.mp3
|
||||||
|
FinialsOrderVoice = 10 //. 定单以完成.mp3
|
||||||
|
ReminderOrderVoice = 11 //. 有人催单了.mp3
|
||||||
|
CancelOrderVoice = 12 //. 定单被取消了.mp3
|
||||||
|
ApplyCancelVoice = 13 //. 申请取消-后台设置播放几次.mp3
|
||||||
|
ApplyRefundVoice = 14 //. 申请退款-后台甚至播放几次.mp3
|
||||||
|
ApplyReturnGoodsVoice = 15 //. 申请退货-后台设置播放几次.mp3
|
||||||
|
DeliverFailVoice = 16 //. 骑手联系不到客户,可能会把商品送回.mp3
|
||||||
|
LoseTokenVoice = 17 //. 失去授权-联播3次.mp3
|
||||||
|
BusinessResponsibilityVoice = 18 //. 商家责任客服退款.mp3
|
||||||
|
EnterTheStoreVoice = 19 //. 进店咨询.mp3
|
||||||
|
StoreOfflineVoice = 20 //. 店铺被下线-联播3次.mp3
|
||||||
|
followVoice = 21 //. 请关注.mp3
|
||||||
|
ElmVoice = 22 //. 饿了么.mp3
|
||||||
|
JdToHose = 23 //. 京东到家.mp3
|
||||||
|
JxStore = 24 //. 京西.mp3
|
||||||
|
MtWmVoice = 25 //. 美团外卖.mp3
|
||||||
|
WmVoice = 26 //. 微盟.mp3
|
||||||
|
TaoBaoVoice = 27 //. 淘宝.mp3
|
||||||
|
JdVoice = 28 //. 京东.mp3
|
||||||
|
PddVoice = 29 //. 拼多多.mp3
|
||||||
|
MtVoice = 30 //. 美团.mp3
|
||||||
|
WdVoice = 31 //. 微店.mp3
|
||||||
|
XdVoice = 32 //. 新店.mp3
|
||||||
|
YzVoice = 33 //. 有赞.mp3
|
||||||
|
ZeroVoice = 34 //. 0.mp3
|
||||||
|
OneVoice = 35 //. 1.mp3
|
||||||
|
TwoVoice = 36 //. 2.mp3
|
||||||
|
ThreeVoice = 37 //. 3.mp3
|
||||||
|
FourVoice = 38 //. 4.mp3
|
||||||
|
FiveVoice = 39 //. 5.mp3
|
||||||
|
SixVoice = 40 //. 6.mp3
|
||||||
|
SevenVoice = 41 //. 7.mp3
|
||||||
|
EightVoice = 42 //. 8.mp3
|
||||||
|
NineVoice = 43 //. 9.mp3
|
||||||
|
TenVoice = 44 //. 10.mp3
|
||||||
|
TwentyVoice = 45 //. 20.mp3
|
||||||
|
ThirtyVoice = 46 //. 30.mp3
|
||||||
|
FortyVoice = 47 //. 40.mp3
|
||||||
|
FiftyVoice = 48 //. 50.mp3
|
||||||
|
SixtyVoice = 49 //. 60.mp3
|
||||||
|
SeventyVoice = 50 //. 70.mp3
|
||||||
|
EightyVoice = 51 //. 80.mp3
|
||||||
|
NinetyVoice = 52 //. 90.mp3
|
||||||
|
OneHundredVoice = 53 //. 100.mp3
|
||||||
|
TwoHundredVoice = 54 //. 200.mp3
|
||||||
|
ThereHundredVoice = 55 //. 300.mp3
|
||||||
|
FourHundredVoice = 56 //. 400.mp3
|
||||||
|
FiveHundredVoice = 57 //. 500.mp3
|
||||||
|
SixHundredVoice = 58 //. 600.mp3
|
||||||
|
SeventyHundredVoice = 59 //. 700.mp3
|
||||||
|
EightHundredVoice = 60 //. 800.mp3
|
||||||
|
NineHundredVoice = 61 //. 900.mp3
|
||||||
|
OneThousandVoice = 62 //. 1000.mp3
|
||||||
|
OrderNoVoice = 63 //. 号定单.mp3
|
||||||
|
BossVoice = 64 //. 老板.mp3
|
||||||
|
EldestBrotherVoice = 65 //. 大哥.mp3
|
||||||
|
EldestSisterVoice = 66 //. 大姐.mp3
|
||||||
|
ToStorePayVoice = 67 //. 到店支付.mp3
|
||||||
|
SpotVoice = 68 //. 点.mp3
|
||||||
|
BalanceEnoughVoice = 69 //. 余额不足5元.mp3
|
||||||
|
MondayVoice = 70 //. 星期一.mp3
|
||||||
|
TuesdayVoice = 71 //. 星期二.mp3
|
||||||
|
WednesdayVoice = 72 //. 星期三.mp3
|
||||||
|
ThursdayVoice = 73 //. 星期四.mp3
|
||||||
|
FridayVoice = 74 //. 星期五.mp3
|
||||||
|
SaturdayVoice = 75 //. 星期六.mp3
|
||||||
|
SundayVoice = 76 //. 星期天.mp3
|
||||||
|
ElementVoice = 77 //. 元.mp3
|
||||||
|
)
|
||||||
|
|
||||||
|
// 菜市商城常量名称
|
||||||
|
const (
|
||||||
|
EBailOrderNoPrint = "eBaiOrderNo" // 品牌名称
|
||||||
|
BusinessTypePrint = "businessType" // 是否为预定单
|
||||||
|
PayOrderTimePrint = "payOrderTime" // 下单时间
|
||||||
|
TrySendTimePrint = "trySendTime" // 预计送达时间
|
||||||
|
OrderNoPrint = "orderNo" // 订单编号
|
||||||
|
VendorNamePrint = "vendorName" // 订单来源平台名称
|
||||||
|
VendorIDPrint = "vendorID" // 订单来源平台id
|
||||||
|
VendorOrderNoPrint = "vendorOrderNo" // 订单序号1/2/
|
||||||
|
EBaiCodePrint = "eBailCode" // 饿百取货码
|
||||||
|
QRCOrderPrint = "qRCOrder" // 订单二维码单号,还是订单Id
|
||||||
|
ConsigneeNamePrint = "consigneeName" // 客户名称
|
||||||
|
ConsigneeMobilePrint = "consigneeMobile" // 客户电话
|
||||||
|
ConsigneeAddressPrint = "consigneeAddress" // 客户地址
|
||||||
|
BuyerCommentPrint = "buyerComment" // 客户备注
|
||||||
|
SkuListPrint = "skuList" // 商品列表
|
||||||
|
SkuNamePrint = "skuName" // 商品名称
|
||||||
|
SkuCountPrint = "skuCount" // 商品件数
|
||||||
|
SkuOnePricePrint = "skuOnePrice" // 商品单价
|
||||||
|
SkuAllPricePrint = "skuAllPrice" // 商品总价 = 商品件数 x 商品件数
|
||||||
|
AllSkuTypeCountPrint = "allSkuTypeCount" // 商品种类
|
||||||
|
AllSkuCountPrint = "allSkuCount" // 商品总数量
|
||||||
|
UserPayMoneyPrint = "userPayMoney" // 用户支付
|
||||||
|
StoreNamePrint = "storeName" // 门店名称
|
||||||
|
StoreTelPrint = "storeTel" // 门店电话
|
||||||
|
OfficialNamePrint = "officialName" // 官方名称
|
||||||
|
BigFontPrint = "bigFont" // 是否为大字体
|
||||||
|
PrintNumberPrint = "printNumber" // 打印次数
|
||||||
|
AppIDPrint = "appId" // 应用id
|
||||||
|
OrderStatusPrint = "orderStatus" // 订单状态
|
||||||
|
WayBillStatusPrint = "wayBillStatus" // 运单状态
|
||||||
|
StoreStatusPrint = "storeStatus" // 门店状态
|
||||||
|
RiderVendorIdPrint = "riderVendorId" // 骑手所属平台id
|
||||||
|
RiderNamePrint = "riderName" // 骑手名称
|
||||||
|
RiderPhonePrint = "riderPhone" // 骑手电话
|
||||||
|
RejectionReasonPrint = "rejectionReason" // 拒收原因
|
||||||
|
CustcareRefundReasonPrint = "custcareRefundReason" // 客服退款理由
|
||||||
|
EnterTheStorePrint = "enterTheStore" // 进店
|
||||||
|
)
|
||||||
@@ -64,6 +64,11 @@ type User struct {
|
|||||||
PopedFlag int `json:"popedFlag"` //被邀请标志(弹框)
|
PopedFlag int `json:"popedFlag"` //被邀请标志(弹框)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserBalance struct {
|
||||||
|
User
|
||||||
|
AccountBalance int64 `json:"accountBalance"` // 银行余额
|
||||||
|
}
|
||||||
|
|
||||||
func (*User) TableUnique() [][]string {
|
func (*User) TableUnique() [][]string {
|
||||||
return [][]string{
|
return [][]string{
|
||||||
[]string{"UserID"},
|
[]string{"UserID"},
|
||||||
@@ -119,9 +124,7 @@ type UserPayment struct {
|
|||||||
|
|
||||||
type UserDeliveryAddress struct {
|
type UserDeliveryAddress struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
||||||
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
|
||||||
|
|
||||||
Tag string `orm:"size(32)" json:"tag"`
|
Tag string `orm:"size(32)" json:"tag"`
|
||||||
ConsigneeName string `orm:"size(32)" json:"consigneeName"`
|
ConsigneeName string `orm:"size(32)" json:"consigneeName"`
|
||||||
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
||||||
@@ -129,14 +132,12 @@ type UserDeliveryAddress struct {
|
|||||||
DetailAddress string `orm:"size(255)" json:"detailAddress"` // 门牌号
|
DetailAddress string `orm:"size(255)" json:"detailAddress"` // 门牌号
|
||||||
Lng float64 `orm:"digits(10);decimals(6)" json:"lng"`
|
Lng float64 `orm:"digits(10);decimals(6)" json:"lng"`
|
||||||
Lat float64 `orm:"digits(10);decimals(6)" json:"lat"`
|
Lat float64 `orm:"digits(10);decimals(6)" json:"lat"`
|
||||||
|
AutoAddress string `orm:"size(255)" json:"autoAddress"` // 这个是通过坐标自动获取的结构化的地址
|
||||||
AutoAddress string `orm:"size(255)" json:"autoAddress"` // 这个是通过坐标自动获取的结构化的地址
|
CityCode int `orm:"default(0);null" json:"cityCode"` // 根据坐标获得
|
||||||
CityCode int `orm:"default(0);null" json:"cityCode"` // 根据坐标获得
|
DistrictCode int `orm:"default(0);null" json:"districtCode"` // 根据坐标获得
|
||||||
DistrictCode int `orm:"default(0);null" json:"districtCode"` // 根据坐标获得
|
Remark string `orm:"type(text)" json:"remark"`
|
||||||
|
IsDefault int8 `json:"isDefault"`
|
||||||
Remark string `orm:"type(text)" json:"remark"`
|
Type int `json:"type"` //1为寄件人,2为取件人(收货人)
|
||||||
IsDefault int8 `json:"isDefault"`
|
|
||||||
Type int `json:"type"` //1为寄件人,2为取件人(收货人)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*UserDeliveryAddress) TableUnique() [][]string {
|
func (*UserDeliveryAddress) TableUnique() [][]string {
|
||||||
|
|||||||
133
business/model/user_vendor_order.go
Normal file
133
business/model/user_vendor_order.go
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserVendorOrder struct {
|
||||||
|
ModelIDCULD
|
||||||
|
UserId string `orm:"size(128);column(user_id);index" json:"userID"` // 用户ID
|
||||||
|
LocalWayBill string `orm:"size(128);column(local_way_bill);index" json:"localWayBill"` // 本地订单ID
|
||||||
|
OtherWayBill string `orm:"size(128);column(other_way_bill);index" json:"otherWayBill"` // 第三方运单ID
|
||||||
|
Goods string `orm:"column(goods)" json:"goods"` // 商品名称
|
||||||
|
GuaranteeValueAmount float64 `orm:"column(guarantee_value_amount)" json:"guaranteeValueAmount"` // 保价金额
|
||||||
|
Weight int `orm:"size(64);column(weight)" json:"weight"` // 重量kg
|
||||||
|
Length int `orm:"size(64);column(length)" json:"length"` // 所有包裹累计长cm
|
||||||
|
Height int `orm:"size(64);column(height)" json:"height"` // 所有包裹累计高cm
|
||||||
|
Width int `orm:"size(64);column(width)" json:"width"` // 所有包裹累计宽cm(向上取整)
|
||||||
|
OrderSendTime string `orm:"size(128);column(orderSendTime)" json:"orderSendTime"` // 预约时间
|
||||||
|
PackageNum int `orm:"size(128);column(package_num)" json:"packageNum"` // 包裹数量
|
||||||
|
ReceiveAddressID int64 `orm:"size(128);column(receive_address_id)" json:"receiveAddressID"` // 收件人地址ID
|
||||||
|
Remark string `orm:"size(512);column(remark)" json:"remark"` // 运单备注
|
||||||
|
SenderAddressID int64 `orm:"size(128);column(sender_address_id)" json:"senderAddressID"` // 寄件人地址ID
|
||||||
|
ThirdPlatform int `orm:"size(16);column(third_platform)" json:"thirdPlatform"` // 第三方平台-京东商家下单传3
|
||||||
|
Type int `orm:"size(8);column(type)" json:"type"` // 快递公司
|
||||||
|
PromiseTimeType int `orm:"size(8);column(promise_Time_type)" json:"promiseTimeType"` // 快递时效产品
|
||||||
|
DeliveryType int `orm:"size(8);column(delivery_type)" json:"deliveryType"` // 产品类型
|
||||||
|
ReallyChannelFee float64 `orm:"column(really_channel_fee)" json:"reallyChannelFee"` // 真实价格
|
||||||
|
ChannelFee float64 `orm:"column(channel_fee)" json:"channelFee"` // 渠道价
|
||||||
|
ServiceCharge float64 `orm:"column(service_charge)" json:"serviceCharge"` // 服务费
|
||||||
|
GuarantFee float64 `orm:"column(guarant_fee)" json:"guarantFee"` // 保价费用
|
||||||
|
OriginalFee float64 `orm:"column(original_fee)" json:"originalFee"` // 原价
|
||||||
|
Bulk float64 `orm:"column(bulk)" json:"bulk"` // 体积抛比系数
|
||||||
|
Increment float64 `orm:"column(increment)" json:"increment"` // 增值(物流)
|
||||||
|
ChannelType int `orm:"size(8);column(channel_type)" json:"channelType"` // 渠道类型(1-快递,2-物流,3-国际物流,4-整车)
|
||||||
|
OrderStatus int `orm:"size(8);column(order_status)" json:"orderType"` // 订单状态(2-待支付,3-支付失败,4-支付成功,10预下单11待取件12运输中15已签收16取消订单17终止揽收,150取消)
|
||||||
|
Img string `orm:"size(1024);column(img)" json:"img"` // 包裹图片
|
||||||
|
IsForward int `orm:"column(is_forward)" json:"isForward"` // 1否,2是 转寄单
|
||||||
|
ErrorMsg string `orm:"size(1024);column(error_msg)" json:"errorMsg"` // 平台错误
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
OrderStatusWaitPay = 2 // 待支付
|
||||||
|
OrderStatusFailPay = 3 // 支付失败
|
||||||
|
OrderStatusSuccessPay = 4 // 支付成功
|
||||||
|
OrderStatusWaitPickup = 5 // 待取件
|
||||||
|
OrderStatusCancel = 150 // 取消订单
|
||||||
|
// 。。。。。
|
||||||
|
)
|
||||||
|
|
||||||
|
func (*UserVendorOrder) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"LocalWayBill"},
|
||||||
|
[]string{"OtherWayBill"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*UserVendorOrder) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"CreatedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeOrderParamReq 下订单请求参数
|
||||||
|
type MakeOrderParamReq struct {
|
||||||
|
PromiseTimeType int `json:"promiseTimeType"` // 快递时效产品
|
||||||
|
DeliveryType int `json:"deliveryType"` // 产品类型
|
||||||
|
Goods string `json:"goods"` // 商品名称
|
||||||
|
GuaranteeValueAmount float64 `json:"guaranteeValueAmount"` // 保价金额
|
||||||
|
Weight int `json:"weight"` // 重量kg
|
||||||
|
Length int `json:"length"` // 所有包裹累计长cm
|
||||||
|
Height int `json:"height"` // 所有包裹累计高cm
|
||||||
|
Width int `json:"width"` // 所有包裹累计宽cm(向上取整)
|
||||||
|
OrderSendTime string `json:"orderSendTime"` // 预约时间
|
||||||
|
PackageNum int `json:"packageNum"` // 包裹数量
|
||||||
|
ReceiveAddressId int64 `json:"receiveAddressId"` // 收件人ID
|
||||||
|
ReceiveAddress string `json:"receiveAddress"` // 收件人地址
|
||||||
|
ReceiveName string `json:"receiveName"` // 收件人姓名
|
||||||
|
ReceivePhone string `json:"receivePhone"` // 收件人手机号
|
||||||
|
Remark string `json:"remark"` // 运单备注
|
||||||
|
SenderAddressId int64 `json:"senderAddressId"` // 寄件人地址Id
|
||||||
|
SenderAddress string `json:"senderAddress"` // 寄件人地址
|
||||||
|
SenderName string `json:"senderName"` // 寄件人姓名
|
||||||
|
SenderPhone string `json:"senderPhone"` // 寄件人手机号
|
||||||
|
ThirdPlatform int `json:"thirdPlatform"` // 第三方平台-京东商家下单传3
|
||||||
|
Type int `json:"type"` // 快递公司
|
||||||
|
ChannelType int `json:"channelType"` // 渠道类型(1-快递,2-物流,3-国际物流,4-整车)
|
||||||
|
Images string `json:"images"` // 包裹图片
|
||||||
|
// 快递费
|
||||||
|
ChannelFee float64 `json:"channel_fee"` // 渠道价
|
||||||
|
Bulk float64 `json:"bulk"` // 体积抛比系数
|
||||||
|
ServiceCharge float64 `json:"service_charge"` // 服务费
|
||||||
|
GuarantFee float64 `json:"guarant_fee"` // 保价费用
|
||||||
|
OriginalFee float64 `json:"original_fee"` // 原价
|
||||||
|
Increment float64 `json:"increment"` // 物流
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserOrderList 用户订单列表
|
||||||
|
type UserOrderList struct {
|
||||||
|
UserId string `orm:"size(128);column(user_id);index" json:"userID"` // 用户ID
|
||||||
|
LocalWayBill string `orm:"size(128);column(local_way_bill);index" json:"localWayBill"` // 本地订单ID
|
||||||
|
OtherWayBill string `orm:"size(128);column(other_way_bill);index" json:"otherWayBill"` // 第三方运单ID
|
||||||
|
Type int `orm:"size(8);column(type)" json:"type"` // 快递公司
|
||||||
|
ReceiveAddressID int64 `orm:"size(128);column(receive_address_id)" json:"receiveAddressID"` // 收件人地址ID
|
||||||
|
SenderAddressID int64 `orm:"size(128);column(sender_address_id)" json:"senderAddressID"` // 寄件人地址ID
|
||||||
|
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"` // 创建时间
|
||||||
|
OrderStatus int `orm:"size(8);column(order_status)" json:"orderType"` // 订单状态(1-待支付,2-支付失败,3-支付成功,4-取件,5-配送,6-,4-取消)
|
||||||
|
ChannelFee float64 `orm:"column(channel_fee)" json:"channelFee"` // 渠道价
|
||||||
|
SendUserName string `orm:"column(send_user_name)" json:"sendUserName"` // 发货人
|
||||||
|
ReceiveUserName string `orm:"column(receive_user_name)" json:"receiveUserName"` // 收货人
|
||||||
|
SenderAddress string `orm:"column(sender_address)" json:"senderAddress"` // 发货城市
|
||||||
|
ReceiveAddress string `orm:"column(receive_address)" json:"receiveAddress"` // 收货城市
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderListRes 查询订单列表
|
||||||
|
type OrderListRes struct {
|
||||||
|
UserVendorOrder
|
||||||
|
UserName string `orm:"column(user_name)" json:"userName"` // 系统用户
|
||||||
|
SendUserName string `orm:"column(send_user_name)" json:"sendUserName"` // 发货人
|
||||||
|
ReceiveUserName string `orm:"column(receive_user_name)" json:"receiveUserName"` // 收货人
|
||||||
|
SenderAddress string `orm:"column(sender_address)" json:"senderAddress"` // 发货城市
|
||||||
|
ReceiveAddress string `orm:"column(receive_address)" json:"receiveAddress"` // 收货城市
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderListReq 请求参数
|
||||||
|
type OrderListReq struct {
|
||||||
|
ExpressType int `json:"expressType"` // 快递公司
|
||||||
|
OrderNo string `json:"orderNo"` // 订单Id
|
||||||
|
OrderStatus int `json:"orderStatus"` // 订单状态
|
||||||
|
PageNum int `json:"pageNum"` // 页码
|
||||||
|
PageSize int `json:"pageSize"` // 页数
|
||||||
|
StartTime time.Time `json:"startTime"` // 开始时间
|
||||||
|
EndTime time.Time `json:"endTime"` // 结束时间
|
||||||
|
}
|
||||||
76
business/model/withdrawal_record.go
Normal file
76
business/model/withdrawal_record.go
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
const (
|
||||||
|
WithdrawalWaitRecord = 1 // 审核中
|
||||||
|
WithdrawalRecordFail = 2 // 审核失败
|
||||||
|
WithdrawalRecordPayFail = 3 // 支付失败
|
||||||
|
WithdrawalRecordPaySuccess = 4 // 支付成功
|
||||||
|
)
|
||||||
|
|
||||||
|
// WithdrawalRecord 提现审核
|
||||||
|
type WithdrawalRecord struct {
|
||||||
|
ModelIDCULD
|
||||||
|
OrderID string `orm:"column(order_id)" json:"orderID"` // 订单号
|
||||||
|
UserID string `orm:"column(user_id);size(48)" json:"userID"` // 用户ID
|
||||||
|
WithdrawalMoney int `orm:"column(withdrawal_money);size(16)" json:"withdrawalMoney"` // 提现金额
|
||||||
|
ServiceCharge int `orm:"column(service_charge);size(16)" json:"serviceCharge"` // 手续费
|
||||||
|
PayMoney int `orm:"column(pay_money);size(16)" json:"payMoney"` // 实际提现金额
|
||||||
|
AlipayAccount string `orm:"column(alipay_account);size(64)" json:"alipayAccount"` // 支付宝账号
|
||||||
|
AlipayName string `orm:"column(alipay_name);size(64)" json:"alipayName"` // 支付宝姓名
|
||||||
|
AlipayOrderId string `orm:"column(alipay_order_id);size(64)" json:"alipayOrderId"` // 支付宝订单号
|
||||||
|
OrderStatus int `orm:"column(order_status);size(8)" json:"OrderStatus"` // 订单状态1-审核中,2-审核失败,3-支付失败,4-支付成功,5-取消
|
||||||
|
PayTime time.Time `orm:"type(datetime);null" json:"payTime"` // 提现支付时间
|
||||||
|
Remark string `orm:"column(remark);type(text)" json:"remark"` // 备注信息
|
||||||
|
Lng float64 `orm:"digits(10);decimals(6)" json:"lng"` // 坐标
|
||||||
|
Lat float64 `orm:"digits(10);decimals(6)" json:"lat"` // 坐标
|
||||||
|
CityCode int `orm:"default(0)" json:"cityCode"` // 提交订单时用户所在城市
|
||||||
|
DistrictCode int `orm:"default(0)" json:"districtCode"` // 城市code
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddWithdrawalRecordReq 用户发起提现申请
|
||||||
|
type AddWithdrawalRecordReq struct {
|
||||||
|
WithdrawalMoney int `json:"withdrawalMoney"`
|
||||||
|
AlipayAccount string `json:"alipayAccount"`
|
||||||
|
AlipayName string `json:"alipayName"`
|
||||||
|
Lng float64 `json:"lng"` // 坐标
|
||||||
|
Lat float64 `json:"lat"` // 坐标
|
||||||
|
CityCode int `json:"cityCode"` // 提交订单时用户所在城市
|
||||||
|
DistrictCode int `json:"districtCode"` // 城市code
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WithdrawalRecord) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"OrderID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WithdrawalRecord) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"UserID", "OrderID"},
|
||||||
|
[]string{"CreatedAt"},
|
||||||
|
[]string{"OrderID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 结构体
|
||||||
|
|
||||||
|
type OrderListParam struct {
|
||||||
|
PageSize int `json:"pageSize"`
|
||||||
|
PageNum int `json:"pageNum"`
|
||||||
|
UserId string `json:"userId"`
|
||||||
|
UserName string `json:"userName"`
|
||||||
|
OrderId string `json:"orderId"`
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
OrderStatus int `json:"orderStatus"`
|
||||||
|
StartTime string `json:"startTime"`
|
||||||
|
EndTime string `json:"endTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WithdrawalListRes struct {
|
||||||
|
WithdrawalRecord
|
||||||
|
Name string `json:"name"`
|
||||||
|
Mobile string `json:"mobile"`
|
||||||
|
AccountBalance int `json:"accountBalance"`
|
||||||
|
}
|
||||||
27
business/q_bida/express_test.go
Normal file
27
business/q_bida/express_test.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package q_bida
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
bida "git.rosy.net.cn/baseapi/platformapi/q_bida"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestQueryExpressPrice(t *testing.T) {
|
||||||
|
param := &bida.GetExpressPriceReq{
|
||||||
|
Type: 0,
|
||||||
|
PromiseTimeType: 0,
|
||||||
|
DeliveryType: 0,
|
||||||
|
GoodsValue: 1,
|
||||||
|
ReceiveAddress: "四川省攀枝花市米易县攀莲镇米易县米易县政府",
|
||||||
|
SendAddress: "四川省成都市锦江区牛市口街道大融厨(九眼桥店)七鑫大酒店",
|
||||||
|
Weight: 2,
|
||||||
|
Length: 0,
|
||||||
|
Height: 0,
|
||||||
|
Width: 0,
|
||||||
|
SendPhone: "18981810340",
|
||||||
|
ChannelType: 2,
|
||||||
|
}
|
||||||
|
data, err := QueryExpressPrice(param)
|
||||||
|
fmt.Println(err)
|
||||||
|
fmt.Println(data)
|
||||||
|
}
|
||||||
716
business/q_bida/q_bida_server.go
Normal file
716
business/q_bida/q_bida_server.go
Normal file
@@ -0,0 +1,716 @@
|
|||||||
|
package q_bida
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
bida "git.rosy.net.cn/baseapi/platformapi/q_bida"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExpressCompany 快递公司
|
||||||
|
var ExpressCompany = []int{
|
||||||
|
bida.JDExpressInt,
|
||||||
|
bida.DBExpressInt,
|
||||||
|
bida.STExpressInt,
|
||||||
|
bida.YTExpressInt,
|
||||||
|
bida.DBAirCraftExpressInt,
|
||||||
|
bida.SFExpressInt,
|
||||||
|
bida.JDDWExpressInt,
|
||||||
|
bida.JDStoreExpressInt,
|
||||||
|
bida.ZTExpressInt,
|
||||||
|
bida.JSTExpressInt,
|
||||||
|
bida.YDExpressInt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogisticsCompany 物流
|
||||||
|
var LogisticsCompany = []int{
|
||||||
|
bida.SXJDExpressInt,
|
||||||
|
bida.SFKYExpressInt,
|
||||||
|
bida.ZTKYExpressInt,
|
||||||
|
bida.KYExpressInt,
|
||||||
|
bida.JDLogisticsExpressInt,
|
||||||
|
bida.DBLogisticsExpressInt,
|
||||||
|
}
|
||||||
|
var Citys = []string{
|
||||||
|
"重庆市",
|
||||||
|
"北京市",
|
||||||
|
"上海市",
|
||||||
|
"天津市",
|
||||||
|
"香港",
|
||||||
|
"澳门",
|
||||||
|
"台湾",
|
||||||
|
}
|
||||||
|
|
||||||
|
const MarkupAmount = 50 // 每公斤加价五毛
|
||||||
|
|
||||||
|
// QueryExpressPrice 查询配送价格,获取所有快递价格
|
||||||
|
func QueryExpressPrice(param *bida.GetExpressPriceReq) (map[string]*bida.GetExpressPriceRes, error) {
|
||||||
|
if param.Weight <= 0 {
|
||||||
|
return nil, errors.New("物品重量必须大于0")
|
||||||
|
}
|
||||||
|
//判断地址是否为直辖市
|
||||||
|
for _, v := range Citys {
|
||||||
|
//寄件
|
||||||
|
if find := strings.Contains(param.SendAddress, v); find {
|
||||||
|
param.SendAddress = v + param.SendAddress
|
||||||
|
}
|
||||||
|
//收件
|
||||||
|
if find2 := strings.Contains(param.ReceiveAddress, v); find2 {
|
||||||
|
param.ReceiveAddress = v + param.ReceiveAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 给快递默认值
|
||||||
|
result := make(map[string]*bida.GetExpressPriceRes, 0)
|
||||||
|
if param.Type == 0 {
|
||||||
|
// 渠道费每公斤加价五毛
|
||||||
|
switch param.ChannelType {
|
||||||
|
case 1: // 快递
|
||||||
|
for i := 0; i < len(ExpressCompany); i++ {
|
||||||
|
param.Type = ExpressCompany[i]
|
||||||
|
fee, err := api.QBiDaAPI.GetExpressPrice(param)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if fee.Code != 0 {
|
||||||
|
result[fmt.Sprintf("%d", ExpressCompany[i])] = fee
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if fee.Data.ChannelFee != 0 {
|
||||||
|
addFee := int(fee.Data.ChannelFee*100) + param.Weight*MarkupAmount
|
||||||
|
fee.Data.ChannelFee = utils.Int2Float64(addFee) / float64(100)
|
||||||
|
result[fmt.Sprintf("%d", ExpressCompany[i])] = fee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2: // 物流
|
||||||
|
for i := 0; i < len(LogisticsCompany); i++ {
|
||||||
|
param.Type = LogisticsCompany[i]
|
||||||
|
fee, err := api.QBiDaAPI.GetExpressPrice(param)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if fee.Code != 0 {
|
||||||
|
result[fmt.Sprintf("%d", LogisticsCompany[i])] = fee
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if fee.Data.ChannelFee != 0 {
|
||||||
|
addFee := int(fee.Data.ChannelFee*100) + param.Weight*MarkupAmount
|
||||||
|
fee.Data.ChannelFee = utils.Int2Float64(addFee) / float64(100)
|
||||||
|
result[fmt.Sprintf("%d", LogisticsCompany[i])] = fee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fee, err := api.QBiDaAPI.GetExpressPrice(param)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if fee.Code != 0 {
|
||||||
|
return nil, errors.New(fee.Msg)
|
||||||
|
}
|
||||||
|
if fee.Data.ChannelFee != 0 {
|
||||||
|
addFee := int(fee.Data.ChannelFee*100) + param.Weight*MarkupAmount
|
||||||
|
fee.Data.ChannelFee = utils.Int2Float64(addFee) / float64(100)
|
||||||
|
result[fmt.Sprintf("%d", param.Type)] = fee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWayOrder 创建快递订单
|
||||||
|
func CreateWayOrder(ctx *jxcontext.Context, param *model.MakeOrderParamReq, userId string) (*model.UserVendorOrder, error) {
|
||||||
|
// 检查价格
|
||||||
|
reallyCannelleFee := param.ChannelFee
|
||||||
|
if err := checkWayFeeIsTrue(param); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第三方数据创建成功,则创建本地数据
|
||||||
|
random := RandomString(5)
|
||||||
|
vendorOrder := &model.UserVendorOrder{
|
||||||
|
UserId: userId,
|
||||||
|
LocalWayBill: utils.Int64ToStr(time.Now().Unix()) + userId[:4] + random, // 当前时间秒数加用户ID前四位
|
||||||
|
OtherWayBill: utils.Int64ToStr(time.Now().Unix()) + userId[:4] + random,
|
||||||
|
PromiseTimeType: param.PromiseTimeType,
|
||||||
|
DeliveryType: param.DeliveryType,
|
||||||
|
Goods: param.Goods,
|
||||||
|
GuaranteeValueAmount: param.GuaranteeValueAmount,
|
||||||
|
Weight: param.Weight,
|
||||||
|
Length: param.Length,
|
||||||
|
Height: param.Height,
|
||||||
|
Width: param.Width,
|
||||||
|
OrderSendTime: param.OrderSendTime,
|
||||||
|
PackageNum: param.PackageNum,
|
||||||
|
ReceiveAddressID: param.ReceiveAddressId,
|
||||||
|
Remark: param.Remark,
|
||||||
|
SenderAddressID: param.SenderAddressId,
|
||||||
|
ThirdPlatform: param.ThirdPlatform,
|
||||||
|
Type: param.Type,
|
||||||
|
ReallyChannelFee: reallyCannelleFee,
|
||||||
|
ChannelFee: param.ChannelFee,
|
||||||
|
ServiceCharge: param.ServiceCharge,
|
||||||
|
GuarantFee: param.GuarantFee,
|
||||||
|
OriginalFee: param.OriginalFee,
|
||||||
|
Bulk: param.Bulk,
|
||||||
|
Increment: param.Increment,
|
||||||
|
ChannelType: param.ChannelType,
|
||||||
|
OrderStatus: model.OrderStatusWaitPay, // 创建待支付
|
||||||
|
Img: param.Images,
|
||||||
|
IsForward: model.YES, //
|
||||||
|
}
|
||||||
|
|
||||||
|
// 事务创建待支付运单,和待支付order
|
||||||
|
db := dao.GetDB()
|
||||||
|
tdb, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db, tdb)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// 添加运单表
|
||||||
|
dao.WrapAddIDCULDEntity(vendorOrder, ctx.GetUserName())
|
||||||
|
if err := dao.CreateEntityTx(tdb, vendorOrder); err != nil {
|
||||||
|
dao.Rollback(db, tdb)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 添加待支付订单表
|
||||||
|
orderPayStatus := &model.Order{
|
||||||
|
OrderID: vendorOrder.LocalWayBill,
|
||||||
|
UserID: vendorOrder.UserId,
|
||||||
|
Type: model.OrderTypePay,
|
||||||
|
OrderType: model.PayType4Express,
|
||||||
|
Way: "",
|
||||||
|
Status: model.OrderStatusWaitPay, // 待支付状态
|
||||||
|
PayPrice: int(vendorOrder.ChannelFee * 100),
|
||||||
|
TransactionID: "",
|
||||||
|
PayFinishedAt: time.Time{},
|
||||||
|
PrepayID: "",
|
||||||
|
OriginalData: "",
|
||||||
|
Comment: "",
|
||||||
|
Lng: 0,
|
||||||
|
Lat: 0,
|
||||||
|
CityCode: 0,
|
||||||
|
DistrictCode: 0,
|
||||||
|
Address: "",
|
||||||
|
PayMethod: 0,
|
||||||
|
}
|
||||||
|
if err := dao.CreateEntityTx(tdb, orderPayStatus); err != nil {
|
||||||
|
dao.Rollback(db, tdb)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dao.Commit(db, tdb)
|
||||||
|
|
||||||
|
return vendorOrder, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelWayOrder 取消运单 todo
|
||||||
|
func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrderReq) (int, error) {
|
||||||
|
var (
|
||||||
|
FailCode = -1
|
||||||
|
SuccessCode = 0
|
||||||
|
tmp_orderNo = param.OrderNo
|
||||||
|
db = dao.GetDB()
|
||||||
|
//txDB orm.TxOrmer
|
||||||
|
)
|
||||||
|
// 查询订单
|
||||||
|
order, err := dao.GetUserVendorOrder(db, userId, param.OrderNo)
|
||||||
|
if err != nil {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
if time.Now().Unix()-order.CreatedAt.Unix() <= 30 {
|
||||||
|
return FailCode, errors.New("支付成功后,超过30s才能取消")
|
||||||
|
}
|
||||||
|
// 待支付或者支付失败
|
||||||
|
switch order.OrderStatus {
|
||||||
|
case model.OrderStatusFailPay, model.OrderStatusWaitPay: // 待支付订单,或者支付失败订单,不需要退款,取消本地订单以及order记录表
|
||||||
|
db := dao.GetDB()
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
order.OrderStatus = model.OrderStatusCancel
|
||||||
|
if _, err := dao.UpdateEntityTx(tx, order, "OrderStatus"); err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
if _, err := dao.UpdateEntityTx(tx, &model.Order{OrderID: param.OrderNo, UserID: userId, Status: model.OrderStatusCancel}, "Status"); err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
tx.Commit()
|
||||||
|
case model.OrderStatusSuccessPay, model.OrderStatusWaitPickup: // 支付成功,取消三方订单,本地转取消状态,,原路退款
|
||||||
|
// 发起QBiDa取消,过去取消通过,则取消本地!不通过,则不予取消!
|
||||||
|
cancelParma := &bida.CancelOrderReq{
|
||||||
|
Genre: param.Genre,
|
||||||
|
OrderNo: order.OtherWayBill,
|
||||||
|
Type: param.Type,
|
||||||
|
}
|
||||||
|
if err := api.QBiDaAPI.CancelOrder(cancelParma); err != nil {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
// 暂时考虑余额支付渠道,加载order表判断支付渠道方式
|
||||||
|
orderWay, err := dao.GetOrderByID(db, tmp_orderNo)
|
||||||
|
if err != nil {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
userBill, err := dao.GetUserBill(db, orderWay.UserID, "")
|
||||||
|
if err != nil {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if orderWay.Status == 110 {
|
||||||
|
if orderWay.PayMethod == 1 { // 余额支付
|
||||||
|
txDB, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
dao.Commit(db, txDB)
|
||||||
|
}()
|
||||||
|
//余额增加金额
|
||||||
|
userBill.AccountBalance += orderWay.PayPrice
|
||||||
|
if _, err := dao.UpdateEntityTx(txDB, userBill, "AccountBalance"); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
//用户运单状态更新
|
||||||
|
order.OrderStatus = model.OrderStatusCancel
|
||||||
|
if _, err := dao.UpdateEntityTx(txDB, order, "OrderStatus"); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if orderWay.PayMethod == 2 { // 微信支付
|
||||||
|
// 微信支付原路退款,发起退款申请
|
||||||
|
res, err := RefundOrderByTL(ctx, orderWay, order, order.OtherWayBill, int(orderWay.PayPrice*100), "申请退款")
|
||||||
|
if len(res.VendorRefundID) > 0 {
|
||||||
|
return SuccessCode, err
|
||||||
|
} else {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if orderWay.PayMethod == 5 { //混合支付
|
||||||
|
//余额增加相应金额
|
||||||
|
mixPayInfo, err := dao.GetMixPayDetail(orderWay.OrderID)
|
||||||
|
if err != nil {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
//userBill.AccountBalance = mixPayInfo.BalancePrice
|
||||||
|
if err := dao.UpdateUserBill(userBill.UserID, mixPayInfo.BalancePrice); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
//if _, err := dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil {
|
||||||
|
// return FailCode, err
|
||||||
|
//}
|
||||||
|
//更新mixPay 状态
|
||||||
|
mixPayInfo.Status = -1 //model.BillMixPayRefund1 //退款状态
|
||||||
|
if _, err := dao.UpdateEntity(db, mixPayInfo, "Status"); err != nil {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := RefundOrderByTL(ctx, orderWay, order, order.OtherWayBill, int(orderWay.PayPrice*100), "申请退款")
|
||||||
|
if len(res.VendorRefundID) > 0 {
|
||||||
|
return SuccessCode, err
|
||||||
|
} else {
|
||||||
|
return FailCode, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return SuccessCode, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryOrderDetail 获取订单详细信息
|
||||||
|
func QueryOrderDetail(typeCode int, orderNo string) (*bida.OrderDetail, error) {
|
||||||
|
detail, err := api.QBiDaAPI.GetOrderDetail(&bida.GetOrderDetailReq{
|
||||||
|
Type: typeCode,
|
||||||
|
OrderNo: orderNo,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 本地查询获取真是支付快递费用
|
||||||
|
sql := `SELECT * FROM user_vendor_order a WHERE a.other_way_bill = ? and a.type = ? `
|
||||||
|
data := &model.UserVendorOrder{}
|
||||||
|
param := []interface{}{orderNo, typeCode}
|
||||||
|
if err := dao.GetRow(dao.GetDB(), data, sql, param); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
addFee := int(detail.PayFee*100) + detail.Weight*MarkupAmount
|
||||||
|
detail.PayFee = utils.Int2Float64(addFee) / float64(100)
|
||||||
|
detail.Images = data.Img
|
||||||
|
return detail, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUserOrderList 查询用户订单列表
|
||||||
|
func QueryUserOrderList(userId string, expressType, orderStatus int, pageNum, pageSize int, orderNo string) ([]*model.UserOrderList, int, error) {
|
||||||
|
sql := `
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS a.type,a.other_way_bill,a.local_way_bill,a.user_id,a.receive_address_id,a.sender_address_id,
|
||||||
|
a.created_at,a.order_status,a.channel_fee,add1.consignee_name send_user_name,add2.consignee_name receive_user_name,
|
||||||
|
district.name sender_address,city.name receive_address
|
||||||
|
FROM user_vendor_order a
|
||||||
|
LEFT JOIN user_delivery_address add1 ON a.sender_address_id = add1.id
|
||||||
|
LEFT JOIN user_delivery_address add2 ON a.receive_address_id = add2.id
|
||||||
|
LEFT JOIN place district ON district.code = add1.city_code
|
||||||
|
LEFT JOIN place city ON city.code = add2.city_code
|
||||||
|
WHERE a.deleted_at = ? AND a.user_id = ?
|
||||||
|
`
|
||||||
|
param := make([]interface{}, 0, 0)
|
||||||
|
param = append(param, utils.DefaultTimeValue)
|
||||||
|
param = append(param, userId)
|
||||||
|
if orderNo != "" {
|
||||||
|
sql = sql + `AND a.other_way_bill = ? OR a.local_way_bill = ? `
|
||||||
|
param = append(param, orderNo, orderNo)
|
||||||
|
}
|
||||||
|
if expressType != 0 {
|
||||||
|
sql = sql + ` AND a.type = ? `
|
||||||
|
param = append(param, expressType)
|
||||||
|
}
|
||||||
|
if orderStatus != 0 {
|
||||||
|
sql = sql + ` AND a.order_status = ? `
|
||||||
|
param = append(param, orderStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取数据条数
|
||||||
|
sql = sql + ` ORDER BY a.created_at DESC LIMIT ? OFFSET ? `
|
||||||
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
|
param = append(param, pageSize, (pageNum-1)*pageSize)
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
var result []*model.UserOrderList
|
||||||
|
db := dao.GetDB()
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := dao.GetRowsTx(tx, &result, sql, param...); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
count := dao.GetLastTotalRowCountTx(tx)
|
||||||
|
dao.Commit(db, tx)
|
||||||
|
|
||||||
|
return result, count, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrder2QBiDa 订单回调成功,且为运费支付时使用该接口
|
||||||
|
func CreateOrder2QBiDa(order *model.UserVendorOrder, orderId string) error {
|
||||||
|
//// 加载订单
|
||||||
|
//order := &model.UserVendorOrder{}
|
||||||
|
//sql := `SELECT * FROM user_vendor_order WHERE local_way_bill = ? `
|
||||||
|
//if err := dao.GetRow(dao.GetDB(), order, sql, []interface{}{orderId}...); err != nil {
|
||||||
|
// return err
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//if order.OrderStatus != model.OrderStatusSuccessPay {
|
||||||
|
// globals.SugarLogger.Debug("Callback Success But Order Status Update Fail ....")
|
||||||
|
// return errors.New("Callback Success But Order Status Update Fail ")
|
||||||
|
//}
|
||||||
|
// 创建QBIDA订单
|
||||||
|
makeOrder := &bida.MakeOrderReq{
|
||||||
|
PromiseTimeType: order.PromiseTimeType,
|
||||||
|
DeliveryType: order.DeliveryType,
|
||||||
|
Goods: order.Goods,
|
||||||
|
GuaranteeValueAmount: order.GuaranteeValueAmount,
|
||||||
|
Weight: order.Weight,
|
||||||
|
Length: order.Length,
|
||||||
|
Height: order.Height,
|
||||||
|
Width: order.Width,
|
||||||
|
OrderSendTime: order.OrderSendTime,
|
||||||
|
PackageNum: order.PackageNum,
|
||||||
|
Remark: order.Remark,
|
||||||
|
ThirdPlatform: order.ThirdPlatform,
|
||||||
|
Type: order.Type,
|
||||||
|
Img: order.Img,
|
||||||
|
}
|
||||||
|
// 获取发货地址以及送货地址
|
||||||
|
// GetAddressDetail 获取配送地址详情
|
||||||
|
sendAddress, err := dao.GetAddressDetail(int(order.SenderAddressID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
makeOrder.SenderAddress = sendAddress.AutoAddress
|
||||||
|
makeOrder.SenderName = sendAddress.ConsigneeName
|
||||||
|
makeOrder.SenderPhone = sendAddress.ConsigneeMobile
|
||||||
|
receiveAddress, err := dao.GetAddressDetail(int(order.ReceiveAddressID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
makeOrder.ReceiveAddress = receiveAddress.AutoAddress
|
||||||
|
makeOrder.ReceiveName = receiveAddress.ConsigneeName
|
||||||
|
makeOrder.ReceivePhone = receiveAddress.ConsigneeMobile
|
||||||
|
otherId, err := createOtherOrder(makeOrder)
|
||||||
|
if err != nil {
|
||||||
|
order.ErrorMsg = err.Error()
|
||||||
|
}
|
||||||
|
order.OtherWayBill = otherId
|
||||||
|
order.OrderStatus = model.OrderStatusWaitPickup
|
||||||
|
order.UpdatedAt = time.Now()
|
||||||
|
if _, err = dao.UpdateEntity(dao.GetDB(), order, "OtherWayBill", "OrderStatus", "UpdatedAt", "ErrorMsg"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RefundOrderByTL 发起取消订单
|
||||||
|
func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.Order, order *model.UserVendorOrder, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
||||||
|
result, err := api.TLpayAPI.PayRefund(&tonglianpayapi.PayRefundParam{
|
||||||
|
Trxamt: refundFee / 100,
|
||||||
|
Reqsn: utils.GetUUID(),
|
||||||
|
Remark: refundDesc,
|
||||||
|
OldTrxID: orderPay.TransactionID,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
orderPayRefund = &model.OrderPayRefund{
|
||||||
|
RefundID: refundID,
|
||||||
|
VendorRefundID: result.TrxID,
|
||||||
|
VendorOrderID: orderPay.OrderID, //本地生成Id
|
||||||
|
Status: model.RefundStatusNo,
|
||||||
|
TransactionID: orderPay.TransactionID, // 支付事务id
|
||||||
|
RefundFee: refundFee,
|
||||||
|
RefundCreatedAt: time.Now(),
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
||||||
|
db := dao.GetDB()
|
||||||
|
if result.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||||
|
globals.SugarLogger.Debug("dfjiaojfiaojfa")
|
||||||
|
orderPayRefund.Status = model.RefundStatusYes
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debug("gedgsedgresgwagwg")
|
||||||
|
orderPayRefund.Status = model.RefundStatusFailed
|
||||||
|
}
|
||||||
|
orderPayRefund.OriginalData = utils.Format4Output(result, true)
|
||||||
|
globals.SugarLogger.Debug("saferhgtrhew", orderPayRefund.OriginalData)
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := dao.CreateEntityTx(tx, orderPayRefund); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
order.OrderStatus = model.OrderStatusCancel
|
||||||
|
if _, err := dao.UpdateEntityTx(tx, order); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debug("rtryjyttyejrthg")
|
||||||
|
orderPay.Status = model.OrderStatusCancel
|
||||||
|
if _, err := dao.UpdateEntityTx(tx, orderPay); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debug("ferbdebere")
|
||||||
|
dao.Commit(db, tx)
|
||||||
|
|
||||||
|
}
|
||||||
|
return orderPayRefund, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ManagerGetOrderList 管理系统查询订单列表
|
||||||
|
func ManagerGetOrderList(param *model.OrderListReq) ([]*model.UserVendorOrder, int, error) {
|
||||||
|
sql := `SELECT SQL_CALC_FOUND_ROWS * FROM user_vendor_order uo WHERE uo.deleted_at = ? `
|
||||||
|
paramSql := make([]interface{}, 0, 0)
|
||||||
|
paramSql = append(paramSql, utils.DefaultTimeValue)
|
||||||
|
result := make([]*model.UserVendorOrder, 0, 0)
|
||||||
|
if param.OrderNo != "" {
|
||||||
|
sql += ` AND (uo.local_way_bill = ? OR uo.other_way_bill = ? )`
|
||||||
|
paramSql = append(paramSql, param.OrderNo, param.OrderNo)
|
||||||
|
if err := dao.GetRows(dao.GetDB(), &result, sql, paramSql...); err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return result, 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if param.StartTime.IsZero() && param.EndTime.IsZero() {
|
||||||
|
sql += ` AND uo.created_at >= ? AND ou.created_at <= ? `
|
||||||
|
paramSql = append(paramSql, param.StartTime, param.EndTime)
|
||||||
|
}
|
||||||
|
if param.ExpressType != 0 {
|
||||||
|
sql += ` AND uo.type = ? `
|
||||||
|
paramSql = append(paramSql, param.ExpressType)
|
||||||
|
}
|
||||||
|
if param.OrderStatus != 0 {
|
||||||
|
sql += ` AND uo.order_status = ? `
|
||||||
|
paramSql = append(paramSql, param.OrderStatus)
|
||||||
|
}
|
||||||
|
if param.PageNum == 0 {
|
||||||
|
param.PageNum = 1
|
||||||
|
}
|
||||||
|
if param.PageSize == 0 {
|
||||||
|
param.PageSize = 10
|
||||||
|
}
|
||||||
|
sql += ` ORDER BY uo.created_at DESC LIMIT ? OFFSET ? `
|
||||||
|
paramSql = append(paramSql, param.PageSize, (param.PageNum-1)*param.PageSize)
|
||||||
|
|
||||||
|
db := dao.GetDB()
|
||||||
|
txdb, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := dao.GetRowsTx(txdb, &result, sql, paramSql...); err != nil {
|
||||||
|
dao.Rollback(db, txdb)
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
count := dao.GetLastTotalRowCountTx(txdb)
|
||||||
|
dao.Commit(db, txdb)
|
||||||
|
return result, count, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrderByLocalId 删除订单
|
||||||
|
func DeleteOrderByLocalId(userId, localId string) (int64, error) {
|
||||||
|
sql := `SELECT * FROM user_vendor_order a WHERE 1=1 AND a.user_id = ? AND a.local_way_bill = ? `
|
||||||
|
paramSql := make([]interface{}, 0, 0)
|
||||||
|
paramSql = append(paramSql, userId, localId)
|
||||||
|
|
||||||
|
data := model.UserVendorOrder{}
|
||||||
|
if err := dao.GetRow(dao.GetDB(), &data, sql, paramSql...); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if data.ID <= 0 {
|
||||||
|
return 0, errors.New("用户数据不存在")
|
||||||
|
}
|
||||||
|
// 待支付,支付失败,取消,可以删除
|
||||||
|
data.DeletedAt = time.Now()
|
||||||
|
if data.OrderStatus == 2 || data.OrderStatus == 3 || data.OrderStatus == 150 {
|
||||||
|
return dao.UpdateEntity(dao.GetDB(), &data, "DeletedAt")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付成功保留15天,可以删除
|
||||||
|
if !data.CreatedAt.IsZero() && data.CreatedAt.AddDate(0, 0, 15).Unix() > time.Now().Unix() {
|
||||||
|
return dao.UpdateEntity(dao.GetDB(), &data, "DeletedAt")
|
||||||
|
}
|
||||||
|
return 0, errors.New("订单完成后保存15天,才可以删除")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOrderStatus 查询所有支付成功的订单
|
||||||
|
func UpdateOrderStatus() {
|
||||||
|
globals.SugarLogger.Debug("每十分钟更新一下订单,定时任务")
|
||||||
|
// 查询状态值为【4-支付成功,10预下单11待取件12运输中17终止揽收】//2,3 15已签收16取消订单 完成订单
|
||||||
|
db := dao.GetDB()
|
||||||
|
sql := `SELECT * FROM user_vendor_order WHERE order_status IN (4,10,11,12,17) AND deleted_at = ?`
|
||||||
|
param := []interface{}{utils.DefaultTimeValue}
|
||||||
|
var data []*model.UserVendorOrder
|
||||||
|
if err := dao.GetRows(db, &data, sql, param...); err != nil {
|
||||||
|
globals.SugarLogger.Debug("Scheduled task Err = ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range data {
|
||||||
|
if v.LocalWayBill == v.OtherWayBill && v.OrderStatus == model.OrderStatusSuccessPay {
|
||||||
|
globals.SugarLogger.Debug("ERROR ", "第三方订单Id写入错误,")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if v.OrderStatus == 2 || v.OrderStatus == 3 || v.OrderStatus == 15 || v.OrderStatus == 16 || v.OrderStatus == 115 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
otherOrder, err := QueryOrderDetail(v.Type, v.OtherWayBill)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debug("Get Order Fail To QBiDa:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
param := model.UserVendorOrder{ModelIDCULD: model.ModelIDCULD{ID: v.ModelIDCULD.ID}}
|
||||||
|
param.OrderStatus = otherOrder.Status + 10
|
||||||
|
if _, err := dao.UpdateEntity(db, ¶m, "OrderStatus"); err != nil {
|
||||||
|
globals.SugarLogger.Debug("Update Order Status Fail ", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TryAgainOrder 再来一单
|
||||||
|
func TryAgainOrder(ctx *jxcontext.Context, oldNo string) (*model.UserVendorOrder, error) {
|
||||||
|
sql := `SELECT * FROM user_vendor_order WHERE local_way_bill = ?`
|
||||||
|
var oldOrder *model.UserVendorOrder
|
||||||
|
if err := dao.GetRow(dao.GetDB(), &oldOrder, sql, []interface{}{oldNo}...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户发货地址信息
|
||||||
|
sendAddress, countSend, err := dao.QueryUserDeliveryAddress(dao.GetDB(), oldOrder.SenderAddressID, nil, 0, 0, 10)
|
||||||
|
if err != nil || countSend != model.YES {
|
||||||
|
return nil, errors.New("查询错误/送货地址信息不正确")
|
||||||
|
}
|
||||||
|
// 获取用户收货
|
||||||
|
receiveAddress, receiveSend, err := dao.QueryUserDeliveryAddress(dao.GetDB(), oldOrder.ReceiveAddressID, nil, 0, 0, 10)
|
||||||
|
if err != nil || receiveSend != model.YES {
|
||||||
|
return nil, errors.New("查询错误/收货地址信息不正确")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询配送费选择最低的
|
||||||
|
fee, err := QueryExpressPrice(&bida.GetExpressPriceReq{
|
||||||
|
Type: oldOrder.Type,
|
||||||
|
PromiseTimeType: oldOrder.PromiseTimeType,
|
||||||
|
DeliveryType: oldOrder.DeliveryType,
|
||||||
|
GoodsValue: oldOrder.GuarantFee,
|
||||||
|
ReceiveAddress: receiveAddress[0].AutoAddress,
|
||||||
|
SendAddress: sendAddress[0].AutoAddress,
|
||||||
|
Weight: oldOrder.Weight,
|
||||||
|
Length: oldOrder.Length,
|
||||||
|
Height: oldOrder.Height,
|
||||||
|
Width: oldOrder.Width,
|
||||||
|
SendPhone: sendAddress[0].ConsigneeMobile,
|
||||||
|
ChannelType: oldOrder.ChannelType,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
param := &model.MakeOrderParamReq{
|
||||||
|
PromiseTimeType: oldOrder.PromiseTimeType,
|
||||||
|
DeliveryType: oldOrder.DeliveryType,
|
||||||
|
Goods: oldOrder.Goods,
|
||||||
|
GuaranteeValueAmount: oldOrder.GuaranteeValueAmount,
|
||||||
|
Weight: oldOrder.Weight,
|
||||||
|
Length: oldOrder.Length,
|
||||||
|
Height: oldOrder.Height,
|
||||||
|
Width: oldOrder.Width,
|
||||||
|
OrderSendTime: oldOrder.OrderSendTime,
|
||||||
|
PackageNum: oldOrder.PackageNum,
|
||||||
|
ReceiveAddressId: oldOrder.ReceiveAddressID,
|
||||||
|
ReceiveAddress: receiveAddress[0].AutoAddress,
|
||||||
|
ReceiveName: receiveAddress[0].ConsigneeName,
|
||||||
|
ReceivePhone: receiveAddress[0].ConsigneeMobile,
|
||||||
|
Remark: oldOrder.Remark,
|
||||||
|
SenderAddressId: oldOrder.SenderAddressID,
|
||||||
|
SenderAddress: sendAddress[0].AutoAddress,
|
||||||
|
SenderName: sendAddress[0].ConsigneeName,
|
||||||
|
SenderPhone: sendAddress[0].ConsigneeMobile,
|
||||||
|
ThirdPlatform: oldOrder.ThirdPlatform,
|
||||||
|
Type: oldOrder.Type,
|
||||||
|
ChannelType: oldOrder.ChannelType,
|
||||||
|
Images: oldOrder.Img,
|
||||||
|
ChannelFee: fee[fmt.Sprintf("%d", oldOrder.Type)].Data.ChannelFee,
|
||||||
|
Bulk: utils.Int2Float64(fee[fmt.Sprintf("%d", oldOrder.Type)].Data.Bulk),
|
||||||
|
ServiceCharge: fee[fmt.Sprintf("%d", oldOrder.Type)].Data.ServiceCharge,
|
||||||
|
GuarantFee: fee[fmt.Sprintf("%d", oldOrder.Type)].Data.GuarantFee,
|
||||||
|
OriginalFee: utils.Interface2Float64WithDefault(fee[fmt.Sprintf("%d", oldOrder.Type)].Data.OriginalFee, 0.0),
|
||||||
|
Increment: fee[fmt.Sprintf("%d", oldOrder.Type)].Data.IncrementFee,
|
||||||
|
}
|
||||||
|
return CreateWayOrder(ctx, param, oldOrder.UserId)
|
||||||
|
}
|
||||||
54
business/q_bida/q_bida_server_utils.go
Normal file
54
business/q_bida/q_bida_server_utils.go
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package q_bida
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
bida "git.rosy.net.cn/baseapi/platformapi/q_bida"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"math/rand"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 检查快递费是否正确
|
||||||
|
func checkWayFeeIsTrue(param *model.MakeOrderParamReq) error {
|
||||||
|
// 检查运费提交是否准确
|
||||||
|
orderWayFee, err := QueryExpressPrice(&bida.GetExpressPriceReq{
|
||||||
|
PromiseTimeType: param.PromiseTimeType,
|
||||||
|
DeliveryType: param.DeliveryType,
|
||||||
|
GoodsValue: param.GuaranteeValueAmount,
|
||||||
|
ReceiveAddress: param.ReceiveAddress,
|
||||||
|
SendAddress: param.SenderAddress,
|
||||||
|
Type: param.Type,
|
||||||
|
Weight: param.Weight,
|
||||||
|
Length: param.Length,
|
||||||
|
Height: param.Height,
|
||||||
|
Width: param.Width,
|
||||||
|
SendPhone: param.SenderPhone,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(orderWayFee[fmt.Sprintf("%d", param.Type)].Data.TypeName, orderWayFee[fmt.Sprintf("%d", param.Type)].Data.Type, orderWayFee[fmt.Sprintf("%d", param.Type)].Data.ChannelFee)
|
||||||
|
if fee, ok := orderWayFee[fmt.Sprintf("%d", param.Type)]; !ok || fee.Code != 0 || fee.Data.ChannelFee != param.ChannelFee {
|
||||||
|
return errors.New("价格核算错误,价格不匹配")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建QBiDa订单
|
||||||
|
func createOtherOrder(param *bida.MakeOrderReq) (string, error) {
|
||||||
|
// 创建三方订单
|
||||||
|
return api.QBiDaAPI.CreateOrder(param)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RandomString 生成随机字符串
|
||||||
|
func RandomString(n int) string {
|
||||||
|
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||||
|
|
||||||
|
b := make([]rune, n)
|
||||||
|
for i := range b {
|
||||||
|
b[i] = letters[rand.Intn(len(letters))]
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
236
business/q_bida/withdrawal_record.go
Normal file
236
business/q_bida/withdrawal_record.go
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
package q_bida
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddUserWithdrawal 用户发起提现操作
|
||||||
|
func AddUserWithdrawal(ctx *jxcontext.Context, param *model.AddWithdrawalRecordReq) error {
|
||||||
|
// 校验用户账户余额是否足够
|
||||||
|
userBill, err := dao.GetUserBill(dao.GetDB(), ctx.GetUserID(), "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if userBill.AccountBalance < param.WithdrawalMoney {
|
||||||
|
return errors.New("账户余额小于可支付余额,请重新申请")
|
||||||
|
}
|
||||||
|
|
||||||
|
//1元以下免费,以上收取对应城市手续费
|
||||||
|
place, err := dao.GetPlaceByCode(dao.GetDB(), param.CityCode)
|
||||||
|
if err != nil || place == nil {
|
||||||
|
return fmt.Errorf("未找到该城市!code:%v", param.CityCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
payOrder := &model.WithdrawalRecord{
|
||||||
|
OrderID: "",
|
||||||
|
UserID: ctx.GetUserID(),
|
||||||
|
WithdrawalMoney: param.WithdrawalMoney,
|
||||||
|
ServiceCharge: 0,
|
||||||
|
PayMoney: 0,
|
||||||
|
AlipayAccount: param.AlipayAccount,
|
||||||
|
AlipayName: param.AlipayName,
|
||||||
|
AlipayOrderId: "",
|
||||||
|
OrderStatus: model.WithdrawalWaitRecord,
|
||||||
|
PayTime: time.Now(),
|
||||||
|
Remark: "",
|
||||||
|
Lng: param.Lng,
|
||||||
|
Lat: param.Lat,
|
||||||
|
CityCode: param.CityCode,
|
||||||
|
DistrictCode: param.DistrictCode,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(payOrder, ctx.GetUserName())
|
||||||
|
payOrder.OrderID = fmt.Sprintf("%d", time.Now().Unix()) + ctx.GetUserID()[:4] + RandomString(4)
|
||||||
|
|
||||||
|
// 核算手续费
|
||||||
|
if param.WithdrawalMoney < 100 {
|
||||||
|
payOrder.ServiceCharge = 0
|
||||||
|
payOrder.PayMoney = param.WithdrawalMoney
|
||||||
|
} else {
|
||||||
|
payOrder.ServiceCharge = utils.Float64TwoInt(float64(param.WithdrawalMoney) * (float64(place.DividePercentage) / float64(100)))
|
||||||
|
payOrder.PayMoney = param.WithdrawalMoney - payOrder.ServiceCharge
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起支付
|
||||||
|
alipayOrder, err := SendPayInfo2Ali(payOrder, param)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := UpdateUserMoney(alipayOrder, userBill); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrder 删除申请订单
|
||||||
|
func DeleteOrder(userId string, id int) error {
|
||||||
|
order := model.WithdrawalRecord{}
|
||||||
|
if err := dao.GetRow(dao.GetDB(), &order, `SELECT * FROM withdrawal_record WHERE id = ? AND user_id = ?`, []interface{}{id, userId}...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
order.DeletedAt = time.Now()
|
||||||
|
if _, err := dao.UpdateEntity(dao.GetDB(), &order, "DeletedAt"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrderListByStatus 用户获取申请订单列表
|
||||||
|
func GetOrderListByStatus(userId string, status, pageSize, pageNum int) (map[string]interface{}, error) {
|
||||||
|
order := make([]*model.WithdrawalRecord, 0, 0)
|
||||||
|
params := make([]interface{}, 0, 0)
|
||||||
|
sql := `SELECT SQL_CALC_FOUND_ROWS * FROM withdrawal_record WHERE user_id = ? AND order_status = ? AND deleted_at = ?`
|
||||||
|
params = append(params, userId, status, utils.DefaultTimeValue)
|
||||||
|
sql += " ORDER BY created_at DESC"
|
||||||
|
sql += " LIMIT ? OFFSET ?"
|
||||||
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
|
params = append(params, pageSize, (pageNum-1)*pageSize)
|
||||||
|
|
||||||
|
db := dao.GetDB()
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
dao.Commit(db, tx)
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := dao.GetRowsTx(tx, &order, sql, params...); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(map[string]interface{}, 2)
|
||||||
|
result["data"] = order
|
||||||
|
result["count"] = dao.GetLastTotalRowCountTx(tx)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserWithdrawalList 管理系统获取提现申请列表
|
||||||
|
func GetUserWithdrawalList(param *model.OrderListParam) ([]*model.WithdrawalListRes, int, error) {
|
||||||
|
sql := `
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS w.* ,u.name,u.mobile,b.account_balance
|
||||||
|
FROM withdrawal_record w
|
||||||
|
LEFT JOIN user u ON w.user_id = u.user_id
|
||||||
|
LEFT JOIN user_bill b ON w.user_id = b.user_id
|
||||||
|
WHERE 1=1 AND w.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParam := make([]interface{}, 0, 0)
|
||||||
|
sqlParam = append(sqlParam, utils.DefaultTimeValue)
|
||||||
|
result := make([]*model.WithdrawalListRes, 0, 0)
|
||||||
|
db := dao.GetDB()
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
dao.Commit(db, tx)
|
||||||
|
}()
|
||||||
|
if param.OrderId != "" {
|
||||||
|
sql += ` AND w.order_id LIKE ? ORDER BY w.created_at DESC LIMIT ? OFFSET ?`
|
||||||
|
sqlParam = append(sqlParam, "%"+param.OrderId+"%", param.PageSize, (param.PageNum-1)*param.PageSize)
|
||||||
|
if err := dao.GetRowsTx(tx, &result, sql, sqlParam...); err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return result, dao.GetLastTotalRowCountTx(tx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if param.UserId != "" {
|
||||||
|
sql += ` AND w.user_id LIKE ?`
|
||||||
|
sqlParam = append(sqlParam, "%"+param.UserId+"%")
|
||||||
|
}
|
||||||
|
if param.UserName != "" {
|
||||||
|
sql += ` AND u.name LIKE ?`
|
||||||
|
sqlParam = append(sqlParam, param.UserName)
|
||||||
|
}
|
||||||
|
if param.Phone != "" {
|
||||||
|
sql += ` AND u.mobile = ?`
|
||||||
|
sqlParam = append(sqlParam, param.Phone)
|
||||||
|
}
|
||||||
|
if param.OrderStatus != 0 {
|
||||||
|
sql += ` AND w.order_status = ?`
|
||||||
|
sqlParam = append(sqlParam, param.OrderStatus)
|
||||||
|
}
|
||||||
|
if param.StartTime != "" {
|
||||||
|
sql += ` AND w.created_at >= ? `
|
||||||
|
sqlParam = append(sqlParam, utils.Str2TimeWithDefault(param.StartTime, utils.DefaultTimeValue))
|
||||||
|
}
|
||||||
|
if param.EndTime != "" {
|
||||||
|
sql += ` AND w.created_at < ? `
|
||||||
|
sqlParam = append(sqlParam, utils.Str2TimeWithDefault(param.EndTime, utils.DefaultTimeValue))
|
||||||
|
}
|
||||||
|
sql += ` ORDER BY w.created_at DESC LIMIT ? OFFSET ?`
|
||||||
|
sqlParam = append(sqlParam, param.PageSize, (param.PageNum-1)*param.PageSize)
|
||||||
|
|
||||||
|
if err := dao.GetRowsTx(tx, &result, sql, sqlParam...); err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return result, dao.GetLastTotalRowCountTx(tx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ManagerExamineWithdrawal 管理员审核提现
|
||||||
|
func ManagerExamineWithdrawal(userId, orderId string, examineStatus int, phone, remark string) error {
|
||||||
|
// 审核不通过
|
||||||
|
if examineStatus != model.YES && remark == "" {
|
||||||
|
return errors.New("拒绝申请原因未填写")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前用户提现订单
|
||||||
|
var order *model.WithdrawalRecord
|
||||||
|
if err := dao.GetRow(dao.GetDB(), &order, `SELECT * FROM withdrawal_record WHERE user_id = ? and order_id = ?`, []interface{}{userId, orderId}...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 审核不通过
|
||||||
|
if examineStatus != model.YES {
|
||||||
|
order.OrderStatus = model.WithdrawalRecordFail
|
||||||
|
order.Remark = remark
|
||||||
|
order.LastOperator = phone
|
||||||
|
order.UpdatedAt = time.Now()
|
||||||
|
_, err := dao.UpdateEntity(dao.GetDB(), order, "OrderStatus", "Remark", "LastOperator", "UpdatedAt")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前用户钱包余额
|
||||||
|
userBill, err := dao.GetUserBill(dao.GetDB(), userId, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if userBill.AccountBalance < order.WithdrawalMoney {
|
||||||
|
order.OrderStatus = model.WithdrawalRecordFail
|
||||||
|
order.Remark = "当前用户余额,小于提现金额。请重新发起支付"
|
||||||
|
order.LastOperator = phone
|
||||||
|
order.UpdatedAt = time.Now()
|
||||||
|
_, err := dao.UpdateEntity(dao.GetDB(), order, "OrderStatus", "Remark", "LastOperator", "UpdatedAt")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return errors.New("账户余额小于可支付余额,请重新申请")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起支付
|
||||||
|
alipayOrder, err := SendPayInfo2Ali(order, &model.AddWithdrawalRecordReq{
|
||||||
|
WithdrawalMoney: order.PayMoney,
|
||||||
|
AlipayAccount: order.AlipayAccount,
|
||||||
|
AlipayName: order.AlipayName,
|
||||||
|
Lng: order.Lng,
|
||||||
|
Lat: order.Lat,
|
||||||
|
CityCode: order.CityCode,
|
||||||
|
DistrictCode: order.DistrictCode,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := UpdateUserMoney(alipayOrder, userBill); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
67
business/q_bida/withdrawal_record_utils.go
Normal file
67
business/q_bida/withdrawal_record_utils.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package q_bida
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/alipayapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SendPayInfo2Ali 发起支付
|
||||||
|
func SendPayInfo2Ali(payOrder *model.WithdrawalRecord, param *model.AddWithdrawalRecordReq) (*model.WithdrawalRecord, error) {
|
||||||
|
if payOrder.WithdrawalMoney <= alipayapi.MinWithdrawalMoney {
|
||||||
|
aliResult, err := api.AliPayAPI.Withdrawal4AliPay(&alipayapi.WithdrawalParam{
|
||||||
|
OutBizNo: payOrder.OrderID,
|
||||||
|
TransAmount: utils.Int2Float64(payOrder.PayMoney) / 100,
|
||||||
|
OrderTitle: "京西生活提现成功",
|
||||||
|
PayeeInfo: &alipayapi.PayeeInfoParam{
|
||||||
|
Identity: param.AlipayAccount,
|
||||||
|
Name: param.AlipayName,
|
||||||
|
},
|
||||||
|
Remark: payOrder.Remark,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil || aliResult.Status != "SUCCESS" {
|
||||||
|
payOrder.OrderStatus = model.WithdrawalRecordPayFail // 支付失败
|
||||||
|
payOrder.Remark = "err:=" + err.Error()
|
||||||
|
} else {
|
||||||
|
payOrder.OrderStatus = model.WithdrawalRecordPaySuccess // 支付成功
|
||||||
|
payOrder.AlipayOrderId = aliResult.OrderId
|
||||||
|
payOrder.PayTime = utils.Str2Time(aliResult.TransDate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return payOrder, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUserMoney 修改数据库
|
||||||
|
func UpdateUserMoney(payOrder *model.WithdrawalRecord, userBill *model.UserBill) error {
|
||||||
|
// 如果支付成功
|
||||||
|
db := dao.GetDB()
|
||||||
|
tx, _ := dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
dao.Commit(db, tx)
|
||||||
|
}()
|
||||||
|
|
||||||
|
switch payOrder.OrderStatus {
|
||||||
|
case model.WithdrawalRecordPaySuccess:
|
||||||
|
userBill.AccountBalance = userBill.AccountBalance - payOrder.WithdrawalMoney
|
||||||
|
if _, err := dao.UpdateEntityTx(tx, userBill, "AccountBalance"); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := dao.CreateEntityTx(tx, payOrder); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case model.WithdrawalWaitRecord, model.WithdrawalRecordFail, model.WithdrawalRecordPayFail:
|
||||||
|
if err := dao.CreateEntityTx(tx, payOrder); err != nil {
|
||||||
|
dao.Rollback(db, tx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
125
conf/app.conf
125
conf/app.conf
@@ -70,7 +70,7 @@ dingdingCallbackURL = "http://callback.test.jxc4.com/dingding/msg"
|
|||||||
dingdingCorpID = "ding7ab5687f3784a8db"
|
dingdingCorpID = "ding7ab5687f3784a8db"
|
||||||
|
|
||||||
alipayAppID = "2019110769024042"
|
alipayAppID = "2019110769024042"
|
||||||
alipayPrivateKey = "MIIEpAIBAAKCAQEAnsbBe0lrK5c4/xhb7ZLDWjGRWmIaj7HyV4LQ9X4EcTV5I5IKLezH1YaNLXytD/VXc5NsJp9IDTFLyOYdXee8lJxAeSQbuBBy1+xLd6qK2JQdVUGP3RZ0pAwVZSc9m0JKj5pYEeA2lvgh4NhSfGEw4BdZacpiDjFWkrQYl+RZkl/eIH2w7sA4wXs/hLSnPiG0VRtLtyYzfGCQdEJNjP5PA6V6CJTd68qTytLnpuaTuVxIYHGGSNd08694b1wOuGpFv6YK+mZkfaGkFoEpp3gUhEQ05duKjNBY71f0ez/Fym7GQYdHNXlsIvCmGQzklkfvQkHj7+MvPpsME4PkqQjRgwIDAQABAoIBAHLzwzDXPtgYbBOEN0oRb43lRS8Cx+gxFRt2goK58c1kwYeXO/dz7loRSDUehs1++wmaOjrcJvYmMpAIykoqdMXDOop6MfdZMUxSr3C78DpNQc9v4BBZKal7diH9/wRhQkolnI2UnvE+RIjdFRsn4pLbVMja1ZMg9WTRLt0JXjAyQZus9pADWADK12OSEIHBvz7/+kiFpq0aM+KPMElQG/mSDg1ESmzfYEbXYmPoiMwU+9frtnprrNdG9h143pb7mdzbXTt/8DbmpFgCfKL7ItpsC3VcZFDsj1Sd3gewrU+FLifH6oPGHTiwEoHNIn5m0RdPVEFoQnQxZnqxzDVBVYECgYEA5zCnBZBLotumxVdIRwncAXKEV5nMHJV2NKVmAc20vHJTsmI4/kA9B2Bjx9jzwwctBzFp1pIadccSbFO48Z5Hn0NdwYOnqba9W50n6R7wO3SnqQuCaoyTAvfkcjrZjZqq88Opa9tKGjD69MFFa+mnK7O7s8B7X6hCa/h80s0zDmkCgYEAr9C5yACb0haAp1WkuYf0B2TyPIofhYOXsjHcJqref+mDHgXSqPntYsXl/RVpJJSAGXJ/CnPd+jHQ0Fis2LuNpZ6ntYzcGoTQtnXx8BdQsnyEjyAvzxWv2JJV12zoSTEW7HL078qqEgbzmort6A8edRiv0kIoNf054QAtv/C9OwsCgYBPATVSlWkDkoR/U8CDZj8kz3miZhB2hC0M+KjPXPiynW80upQ3bsRsTOhMVzuWHlGo7533kZ4xOYJ2OnYtO6XGK0NS6ibVvHkhYadN5yC5cLgK8L/0oW1rykLrNmk6FuzsuKShEyNTqAFauuF6azKRoK44U0LWAa4RL62YbD9SYQKBgQCD0Qp5WXt6WES9MQj/0V607IpxuV1IzRC/GYLlutZ3MKyNpe/7oObKV3XH+nWKZ4xjh+SYAac8Hn1guBtfo77fncQ/6gxcFZgmNOfgCpsGNzVr2cX+jVP6HD0f9xdxSMzXGplp75jzSyL5i5AznKJJSOkJy3A6ilEK0Qd8ERLPYQKBgQC/QSV0c71x3nYz3koOQv7s36i5R0jeHnadSMyGUlrYmn/TaXj0KaUaEYRcgJyWB/dxy3cde8EKlqg0q80Zc6ExkZKhpO6k1lj9Bta+l+KAyVFroYDIy/b0Wukr2qV1mkMK0FQ0X2hVbv6TJBq5RMNeYAy1shOeWIwaS5muSYm4Ig=="
|
alipayPrivateKey = "MIIEogIBAAKCAQEAilPMZeE7xXewRQrfwmbEbYgfn5oY5NHUR5RSbgaDohp6CdtOXL1IGEMuQ/OA3Zrx7Yd5Et5rX7d+k3BUz42k+7Xxu2opk3mBZB2UGWvBLzMcWCE0K/OQH89cJl8N3NX1V2ylrmhNQIqbRfkFunc1dnovhPZBzgSUDHnRcc4JzRI79/6HMxUN36+gfnkShhp92flM1ZYdpj6dYtwWiz5geaCXCLS9RVDIAN+6wl2ie9fiEu4gL8XWi+BrESGUC0R/r9QjoAir+5c7xAbdIPHqhRnXz18xoJorBtLnaMbYR3hoMZq/b4AgukgOJEPwsiewCGMqsyyZRAli9jFQHPByiQIDAQABAoIBAHncqU13x7iHYPryQX56GsKEEZgBoby0PldxC81yX7UHrkvQsJBzEHiPdsrWUsjoIAoqNzewStfgR9qMM6tGFfrKp1N8i3Qorx0MEdTzYRW76VSaq+Osh2P+wifrxcKvm5yRUsT7jlM1yOU0JR/ItYjSy9pPOFnPHr5+801XPrsx8aC+4ZS9oLewyou8yB0piRbyk4PiY2lf/JP6TkQt85ajNjcTLOTh+xLmIR692Z5mJcRT3N+yekpYrETAs4TiSQNgM/C17KreXjJQ97257rqcvOzdvAQwkus9kpbStFTadGMZAp5Q+ItbfDhKY0n/x9h50thoLUZBBk7Y8Bx3qCECgYEAvSKy0KxgZjr4Zw7utj6VNnSWLzkXVVpD2GjuHQgMe4tWm5xBBAbx8W72Y2sgHBoYUNtnblNmNgA1QI2/EtUWdGRnXePXu6RxB+I21PUDNw2hCXUR0v8dPxd80Yxjii31LSutEPq7NNeWkV3RNJal5ejc6RDT7nhQ9M4y8gXp7xsCgYEAuzrQVO1dVaT+KHXJV2AqjL3EQxOMQ8r9MMsBXicXZdm4faFnwIPdXcRPxBNjKK6UziV/ztNUw5IBQyReh9sG7ZRijz8S5+UF4hTA+5W8xb//EaK5TnJ3rP2zPnTkqCEJu/BERzx1paHVPq7LbxQmlVcHyODVktv5W+OJULFvaysCgYAdNKZ4IqYgIysIfv3NloxkBEzMrfw0aePgHxPl18BVs4aEMPS5MnlZ1tClOX2T2VO36KloF+jIne+bMEg5GD6HapmrnetKRnJNzVi6ObttXOVpGHLQKiTSAUZ89TjJtZ8OgpgO7yjJWCEgAWS0wi6L+hFiy/5t7JZTtyOWy+L70QKBgCOnT4TcrqlgggWyaGT7Kx8iA/3B+zPts8lW3yvOxeXfUAKceeVvNvhkKcxs5LUaibu36F66X6neY98lTdsRGoCjgSFGIZOHSVeEHDvMh+YgabIyCpeltKR8q2V5XRGnOPNRDa+DE+Q2rSUCpDrC25YUvKbEKeeNfC7DZaK4Jz+BAoGAPEYYdZXtQbOCXGyPU6CS6W5a2IlOWIpDFCMD+S+qFZBnkqCtBgS0CtQGLEL5t4gYsOBuWUreIxy0UAUIlFFGsDmwqsHu9jHi49LDcAhkciV886nYb/2qCFXo6oiZRBV65Xfai973dHqaVftmZWBsLT+cKJ7eRYHx//uGyJWe/04="
|
||||||
|
|
||||||
mtUnionAppKey = "b6481f92b47918cd6e42e7ea4fae6084"
|
mtUnionAppKey = "b6481f92b47918cd6e42e7ea4fae6084"
|
||||||
mtUnionAppSecret = "84d390777ddf691ff092e744ba26bfdd"
|
mtUnionAppSecret = "84d390777ddf691ff092e744ba26bfdd"
|
||||||
@@ -88,6 +88,14 @@ addEvent = true
|
|||||||
|
|
||||||
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|
||||||
|
#QBIDA 账号
|
||||||
|
QBiDaAccess = "18048531223"
|
||||||
|
QBiDaPassword = "18080188338"
|
||||||
|
|
||||||
|
#话费充值平台 账号
|
||||||
|
AccountNo = "cdrxqgmc"
|
||||||
|
PasswordNo = "cdrxqgmc1234"
|
||||||
|
PhoneScenery = "cdrxqgmc123456"
|
||||||
[beta]
|
[beta]
|
||||||
enableStoreWrite = true
|
enableStoreWrite = true
|
||||||
enableJdStoreWrite = false
|
enableJdStoreWrite = false
|
||||||
@@ -167,6 +175,14 @@ yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4"
|
|||||||
|
|
||||||
aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
||||||
|
|
||||||
|
#QBIDA 账号
|
||||||
|
QBiDaAccess = "18048531223"
|
||||||
|
QBiDaPassword = "18080188338"
|
||||||
|
|
||||||
|
#话费充值平台 账号
|
||||||
|
AccountNo = "cdrxqgmc"
|
||||||
|
PasswordNo = "cdrxqgmc1234"
|
||||||
|
PhoneScenery = "cdrxqgmc123456"
|
||||||
[rsm]
|
[rsm]
|
||||||
EnableDocs = true
|
EnableDocs = true
|
||||||
|
|
||||||
@@ -271,72 +287,19 @@ tbUnionAppSecret = "2c2bce02eab860d486f68aa59a0127d9"
|
|||||||
pddAppKey = "f9d95aaf5856485eabf39588f69a86de"
|
pddAppKey = "f9d95aaf5856485eabf39588f69a86de"
|
||||||
pddAppSecret = "fa40c1fe356eebc1376ace1d2380ed44e553c602"
|
pddAppSecret = "fa40c1fe356eebc1376ace1d2380ed44e553c602"
|
||||||
|
|
||||||
|
#QBIDA 账号
|
||||||
|
QBiDaAccess = "18048531223"
|
||||||
|
QBiDaPassword = "18080188338"
|
||||||
|
|
||||||
|
#话费充值平台 账号
|
||||||
|
AccountNo = "cdrxqgmc"
|
||||||
|
PasswordNo = "cdrxqgmc1234"
|
||||||
|
PhoneScenery = "cdrxqgmc123456"
|
||||||
[print]
|
[print]
|
||||||
httpport = 8088
|
httpport = 8088
|
||||||
EnableDocs = false
|
EnableDocs = false
|
||||||
|
|
||||||
jdOrgCode = "320406"
|
dbConnectStr = "root:WebServer@1@tcp(gold1.int.jxc4.com:3306)/api?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
jdLoginName = "jd_jxcs1223"
|
|
||||||
jdToken = "29afd5a8-f93f-4d4c-9fce-a7297340af59"
|
|
||||||
jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d"
|
|
||||||
jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4"
|
|
||||||
|
|
||||||
jd2OrgCode = "349454"
|
|
||||||
jd2Token = "29e0e567-c475-433a-aff0-37176ee8d8a7"
|
|
||||||
jd2AppKey = "7fb947624ff847ae94ff2f068cc99652"
|
|
||||||
jd2Secret = "1097abd7ef09427099b4922784af123a"
|
|
||||||
|
|
||||||
jd3OrgCode = "359459"
|
|
||||||
jd3Token = "5e2c0a60-4450-40c0-a1da-b560051251ea"
|
|
||||||
jd3AppKey = "21b627c23ea04c69b64b48d0b361213e"
|
|
||||||
jd3Secret = "51cd27a748e64c829b4b7f83f4844610"
|
|
||||||
|
|
||||||
jdEclpAccessToken = "bcb6201b5b3c45a0976dcda5e2dea8aejiwm"
|
|
||||||
jdEclpAppKey = "0D397F05CF11C51BCDCC81744680EBC3"
|
|
||||||
jdEclpAppSecret = "f16a5e57ff4f4f428b702c40d2d4b933"
|
|
||||||
|
|
||||||
jdShopAccessToken = "de8157b447584885910f429011e49cb93yjq"
|
|
||||||
jdShopAppKey = "E1D746D42474D5F1F1A10CECE75D99F6"
|
|
||||||
jdShopAppSecret = "efa7e1d1a22640fa990e6cf164b28608"
|
|
||||||
jdsCookie = "shshshfpa=13b38d4a-8ba0-df12-0012-82d9a37fb835-1573795914; shshshfpb=abYp8Dq5JobRtp2pkZa7MbA%3D%3D; __jdu=1142616513; pinId=WMIzMhF5BfL6nJp9AcA2-A; pin=shop_jxcs; unick=shop_jxcs; _tp=7FBEvLyPe%2FKcgxsfY5lRgA%3D%3D; _pst=shop_jxcs; areaId=22; ipLoc-djd=22-1930-50948-57092; user-key=3ec204b4-f204-4320-98e3-b2569c757800; cn=0; shshshfp=5d23828ee6ea3a33e1a58588db1713f8; 3AB9D23F7A4B3C9B=AK36FFYF5J6WMPRH7YTXMEX4CATHR6NAA3IQEESU2I33FEJRQ3DRLU4SZJYD2XGFLCFW43DHYP5HQKOMR4EFQSLKLA; navigation=[%22shop_jxcs%22]; __jdv=122270672|baidu|-|organic|not set|1589514011252; language=zh_CN; ceshi3.com=000; csrf_token=b84d0a5c-6288-4db4-84e1-cadf66be3bf7; mba_muid=1142616513; TrackID=1qvZk-6QSAOp1NmaouJGEx58_cFglCFv57HEfoHOezMrOnV3_FSK-5ExeYhHx97IltBADG3dvJqLIt3P57wyUW4Z2Q3Y8ITo8Cfdmlz3kykM; RT="z=1&dm=jd.com&si=mcot45862q&ss=kaf1rcqz&sl=2&tt=38t&ld=22qx&nu=b99e5a7f32b36f184614d34a1d926a39&cl=3clu&ul=3crs&hd=3cz3"; b-sec=S2JWP6CAFP7K4I6PXVBUVCO6YVXUX2JAPDHLX5RZUDE4YKCGOEXJIINB3Q4THCFCMVWZPFAYGLWLG; thor=80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0AB6BF053A5325612EC0407791BB05F5301356E71E8B282C40C06D0B5DF3439DEECB102A78FAFF7AC0FC4E2D1FA8DD8BBAE1A011E50B5C74F1870AD982D7BF453F470F31F2241B73AC4C25485025C2ABEBC8A538AF7257824D2FAEE300A1435175B0B451FB5C19B78D729FC83152CA3BAF; _vender_=TNK3O6PALVQGGA33SGBIUTOKL4OOE6DP6OMNVIPMAMULGTRFWUMTVWGFRUTYP4L4EPN3KP73P33BOBN5SNJFBNQB5OMQYSJ5MORGQLJS7QAPOMIN7AZD6B3ZLP2DV4JCXDI5P3KOXJ3PHLIIRZ2YVS4JSSA3JRSBACNLJSC24ELO46GIMRW53XGW36EBPLZMZP2MQCAMJNO44FKT46B7VDVT7KQTELESOOF6E377AYC3NWKQF6ICIYBW4BA4JL5QG2NHGNOHOUJDNUW3N22UF32DLFLEIQGVO2W55J6AKPPBT227XA5NO4S3NFVIUUUADGOYH56T72MTNXCILWVMN4RMUNVFMGL4ISGXJS7YILE7A2ESPAU43MISAOZM2BR53MGRB5OZSQZPV5DBDCN2OVVT3XT5N2VMFELARQNTMAJCDBGXFURSN2Q7SYULLKZEZHTYWWOI65LS5OIHLUZQKWFGMNSQF2UBSYV7FG46CWJGMVHOGV3FY4RUEVJK6BQ223QK3H3VMTHXCZOZV4GKR5EWGIZZDVUAK4B36BPA5HPBO7PXKBOEXEBX77IYBNQLCGMK72J4VKNOUPYKNB5JE5D5UN3R2MMFGLJARTL2QTC5ZRZ4PJCJZWWOV37VWLWFVAN5IGHPAYME73KTNFABM5W73XLOXJFQWTFRZEK3FCL3BLRV4UOXLBQGA34R4WUBYSZURMKTXXB7U; __jda=65775340.1142616513.1573036516.1589946171.1589952725.54; __jdb=65775340.147.1142616513|54.1589952725; __jdc=65775340; _base_=YKH2KDFHMOZBLCUV7NSRBWQUJPBI7JIMU5R3EFJ5UDHJ5LCU7R2NILKK5UJ6GLA2RGYT464UKXAI4Z6HPCTN4UQM3WHVQ4ENFP57OC2DC7JQLRXRUO5PW6B77O6UXAZ4TCNE6YVKRXISVLBYGYO44RCDDPWDA4AEL7ZLXI2SG4SOQWCP5WPWO6EFS7HEHMRWVKBRVHB33TFD4SMNBHRJCTDFHU6SZXCZD6RFXX2OORYGL5H2GYF2IIH2KKD4T72IR4F577G2E5II2OMMXYF2GDYNTS7WGAUXFEWRJ3CTKDBDWMHUKJQF4ZFOTNBBYBIZRXZYERXXIG6ATJFKID7XOR3NQ2CL6K7A2IEZV5HCBNYDPXFCM2ZMCS474KZ44S5F; _vender_new_=GI63BGTJFDBQ46CD7JXUX3HEPM4P5LEA3TJTFGW4ZGGIVOLTPK5T25EXTBLCENPUTR7E2I23YDFQ4ARO6JW3NHSWBDE73RTUKJTADIPFPLYFE3ARGJUBPHWUIONS72KRQOZC5P7PB4VPPLRHGEP7L3Z5K62L2E2MGTWHFJRQ3CAVBDYVW2Z4J6U73HW4BKKOCDAH5T6OJJKWKLBZFOTI7342QSL7YQ2E3I4T777RNZF23XGOTCP3D4INHNO5MNKT3XJZQBVHWUVZYQUXCK5QQTKWADKQUCYV3JRY6YAYOD7Z5IIKGNLREQTCPO7SYGSIS655JUGOUILFLXVZE6KCFG7ZTPRUD6VPE4KCIE4OUZSED6FTSEZHTM363E7XXCHB4NA7VLZHCQSBHDVGMRA7RM4RGJC3MOI4TJNGCLW6QKUCCZAY7XTGOTMC53TFUYERGNIH2RBULZ7UTZH5GU3TC6RWFI2QL4QTAIARA6GNVXENEOYIPZEHN222YDAJX5OBBEECAMAPNKZ3XNF5CNGDJ3DSU2ZLOCAKLFPCYTIIWPPJMCQ636F5464HS4OVFPFNIDW4OCE23JRPYP5FAL6TKHPAC3H3ZRU7WA5GKJJKBZUGIX7NEO4LZB7FJ3RZZZH3UHPQMNILD5DT2V7HVCUOVNOFBEOW5ID2ZMQ3XV264IU4MYHN64RA; _BELONG_CLIENT_=WPSC4XJXWK5USS4JNZY2X7VRLR5MCBKRSVHEXABGTHDGISIQK5YOLZUXYE7IOIM7MOKO74H6CRN6WHAAR4TMDV3XZWMXZRCRT5XRNE3V356BTOB2Y7LPK66VWQK6HPTGWVXIDXDCPVE3W5WMHAIO6AT2LX2XXVNUCXR34ZWFK6HY45CORGIKOSYDYZBF27WOKTUX6BS4FZMIJWNUX6CB4JAA25ZLF7ZEKYOO4QV5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BMTUJZACIBHXQFAVLRF76VQY5PNJGGJNBEZHSFYYJA3YORRT7FB5AHCOIFQKF3W5RWNUX6CB4JAA26JNMO7AYWNUPZF5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BWZDKMOJ5BS6II53ERY6ALV3ZWPF42L4CPUHEGPYIII35KDC4FCNVCORCXFD6IVNLBEDPB2GGP4UHWNRUDOQBDIW7RZJXBA2WV5ANZOTEGUCDWYRVQS2YUTIZNZ276PRYG4N56V6YTII7MBKBC7LYHO7C555HTSBXGNRM3E466AYN67DHWVM5HQFJ4NFDO5BTOKMOS5L2CXFVYDR2FCOILVYPEI; _lvtc_=5ZH3OJ7CWYNVGEKDRC32XTFXGY"
|
|
||||||
|
|
||||||
elmIsProd = true
|
|
||||||
elmToken = ""
|
|
||||||
elmAppKey = "KLRDcOZGrk"
|
|
||||||
elmSecret = "1fc221f8265506531da36fb613d5f5ad673f2e9a"
|
|
||||||
|
|
||||||
ebaiSource = "34665"
|
|
||||||
ebaiSecret = "c3db75b754ea2d89"
|
|
||||||
|
|
||||||
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
|
||||||
mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE"
|
|
||||||
|
|
||||||
weixinAppID = "wx70d0943e61e0d15c"
|
|
||||||
weixinAppSecret = "c2908eeab509314936c4f535dc03e6de"
|
|
||||||
weixinID = "wxae51106db0b585d5"
|
|
||||||
weixinSecret = "a91ffcc507d332028cfca7788b424323"
|
|
||||||
weixinMiniAppID = "wxa4a76d7b4c88604e"
|
|
||||||
weixinMiniSecret = "dc0fd8dc3042f383347e0502b73ab1d2"
|
|
||||||
|
|
||||||
yinbaoAppKey = "682628966212343269"
|
|
||||||
yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4"
|
|
||||||
|
|
||||||
aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
|
||||||
|
|
||||||
wxpayAppID1 = "wx70d0943e61e0d15c"
|
|
||||||
wxpayAppID2 = "wxa4a76d7b4c88604e"
|
|
||||||
wxpayAppID3 = "wx2bb99eb5d2c9b82c"
|
|
||||||
wxpayAppKey = "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD"
|
|
||||||
wxpayAppMchID = "1603491062"
|
|
||||||
wxpayAppMchID2 = "1413203902"
|
|
||||||
wxpayNotifyURL = "http://callback.rsm.jxc4.com/wxpay/msg/"
|
|
||||||
|
|
||||||
tonglianPayAppID = "00183083"
|
|
||||||
tonglianPayKey = "18048531223"
|
|
||||||
tonglianPayCusID = "56065105499TVAH"
|
|
||||||
tonglianPayNotifyURL = "http://callback.rsm.jxc4.com/tonglian/msg/"
|
|
||||||
|
|
||||||
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
|
||||||
|
|
||||||
enableStoreWrite = true
|
enableStoreWrite = true
|
||||||
enableJdStoreWrite = true
|
enableJdStoreWrite = true
|
||||||
@@ -345,33 +308,11 @@ enableMtwmStoreWrite = true
|
|||||||
enableWscStoreWrite = true
|
enableWscStoreWrite = true
|
||||||
enableYbStoreWrite = true
|
enableYbStoreWrite = true
|
||||||
enableJdShopWrite = true
|
enableJdShopWrite = true
|
||||||
|
#QBIDA 账号
|
||||||
|
QBiDaAccess = "18048531223"
|
||||||
|
QBiDaPassword = "18080188338"
|
||||||
|
|
||||||
disableWeimob = false
|
#话费充值平台 账号
|
||||||
weimobCallbackURL = "http://callback.jxc4.com/weimob"
|
AccountNo = "cdrxqgmc"
|
||||||
|
PasswordNo = "cdrxqgmc1234"
|
||||||
dingdingAgentID = 239461075
|
PhoneScenery = "cdrxqgmc123456"
|
||||||
dingdingAppKey = "ding7iu9cptairtcls0c"
|
|
||||||
dingdingSecret = "LWrZAFeqUfuVv7n_tc8vPpCAx6PT4CwManx2XCVhJOqGsx2L5XCDuX1sAN_JtvsI"
|
|
||||||
|
|
||||||
dingdingCallbackURL = "http://callback.jxc4.com/dingding/msg"
|
|
||||||
|
|
||||||
pushAppID = "5lyyrvHODG6wC8Sdr3a9h"
|
|
||||||
pushAppKey = "iFrkUDmR2g5eqQpfh2kQ57"
|
|
||||||
pushAppSecret = "WTn53qd6WAAdLMXfmXvzb7"
|
|
||||||
pushMasterSecret= "dGZcR0XGGg7H5Pd7FR3n47"
|
|
||||||
|
|
||||||
ejyPlatName = "1Zbve"
|
|
||||||
ejyBeforeKey = "htvse3XEDhBnCTNo"
|
|
||||||
ejyAfterKey = "QM5RnGl6kNh3ENLT"
|
|
||||||
|
|
||||||
txCloudSecretID = "AKIDFNmm1U7vhITlVItry0ng5Q268lGjDZyQUR6"
|
|
||||||
txCloudSecretKey = "25p3aynr97hOMJEfpvr0LoXD0gI62l7wcHA7nsM6"
|
|
||||||
|
|
||||||
mtUnionAppKey = "b6481f92b47918cd6e42e7ea4fae6084"
|
|
||||||
mtUnionAppSecret = "84d390777ddf691ff092e744ba26bfdd"
|
|
||||||
|
|
||||||
tbUnionAppKey = "32724809"
|
|
||||||
tbUnionAppSecret = "2c2bce02eab860d486f68aa59a0127d9"
|
|
||||||
|
|
||||||
pddAppKey = "f9d95aaf5856485eabf39588f69a86de"
|
|
||||||
pddAppSecret = "fa40c1fe356eebc1376ace1d2380ed44e553c602"
|
|
||||||
496
controllers/api_controller.go
Normal file
496
controllers/api_controller.go
Normal file
@@ -0,0 +1,496 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"github.com/astaxie/beego/client/orm"
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ApiController struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
keyAppID = "app_id"
|
||||||
|
keyTimestamp = "timestamp"
|
||||||
|
keyMethod = "method"
|
||||||
|
keySign = "sign"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
keyPrintNo = "print_no"
|
||||||
|
keyPrintKey = "print_key"
|
||||||
|
keyName = "name"
|
||||||
|
keyStatus = "status"
|
||||||
|
keyOrderNo = "order_no"
|
||||||
|
keyContent = "content"
|
||||||
|
keyMsgID = "msg_id"
|
||||||
|
keySound = "sound"
|
||||||
|
keyVolume = "volume"
|
||||||
|
keySim = "sim"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
routerMap map[string]reflect.Value
|
||||||
|
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
routerMap = make(map[string]reflect.Value)
|
||||||
|
var ruTest ApiController
|
||||||
|
vf := reflect.ValueOf(&ruTest)
|
||||||
|
vft := vf.Type()
|
||||||
|
//读取方法数量
|
||||||
|
mNum := vf.NumMethod()
|
||||||
|
fmt.Println("mNum", mNum)
|
||||||
|
//遍历路由器的方法,并将其存入控制器映射变量中
|
||||||
|
for i := 0; i < mNum; i++ {
|
||||||
|
mName := vft.Method(i).Name
|
||||||
|
routerMap[mName] = vf.Method(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title api调用入口
|
||||||
|
// @Description api调用入口
|
||||||
|
// @Param app_id formData string false "应用ID"
|
||||||
|
// @Param timestamp formData int64 false "unix时间戳"
|
||||||
|
// @Param sign formData string false "签名"
|
||||||
|
// @Param method formData string false "接口名"
|
||||||
|
// @Success 200 {object} controllers.CallResult2
|
||||||
|
// @Failure 200 {object} controllers.CallResult2
|
||||||
|
// @router /CallOpenAPI [post]
|
||||||
|
func (c *ApiController) CallOpenAPI() {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
errCode = model.ErrCodeGeneralFailed
|
||||||
|
callResult = &CallResult2{}
|
||||||
|
accessID = utils.GetUUID()
|
||||||
|
requireParams []string
|
||||||
|
dataMap = make(map[string]interface{})
|
||||||
|
now = time.Now().Unix()
|
||||||
|
parms, result []reflect.Value
|
||||||
|
urls = url.Values{}
|
||||||
|
app = &model.Apps{}
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
var (
|
||||||
|
appID int
|
||||||
|
sign, method string
|
||||||
|
timestamp int64
|
||||||
|
)
|
||||||
|
//判断必传参数是否传入begin
|
||||||
|
if appID, err = c.GetInt(keyAppID); err != nil {
|
||||||
|
requireParams = append(requireParams, keyAppID)
|
||||||
|
}
|
||||||
|
if method = c.GetString(keyMethod); method == "" {
|
||||||
|
requireParams = append(requireParams, keyMethod)
|
||||||
|
}
|
||||||
|
if sign = c.GetString(keySign); sign == "" {
|
||||||
|
requireParams = append(requireParams, keySign)
|
||||||
|
}
|
||||||
|
if timestamp, err = c.GetInt64(keyTimestamp); err != nil {
|
||||||
|
requireParams = append(requireParams, keyTimestamp)
|
||||||
|
}
|
||||||
|
if len(requireParams) > 0 {
|
||||||
|
err = buildParamRequiredErr(requireParams)
|
||||||
|
}
|
||||||
|
//判断必传参数是否传入end
|
||||||
|
if err != nil {
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
//判断timestamp传入是否正确begin
|
||||||
|
if len(utils.Int64ToStr(timestamp)) != len(utils.Int64ToStr(now)) {
|
||||||
|
err = buildTimestampParamErr()
|
||||||
|
errCode = model.ErrCodeOpenAPIParamErrTimeStamp
|
||||||
|
}
|
||||||
|
//判断timestamp传入是否正确end
|
||||||
|
if err != nil {
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
//判断app_id和sign匹配begin ,sign = app_id + app_key + timestamp的MD5加密
|
||||||
|
app.ID = appID
|
||||||
|
if err = dao.GetEntity(db, app); err != nil {
|
||||||
|
if err == orm.ErrNoRows {
|
||||||
|
err = fmt.Errorf("未查询到该应用!app_id: %v", appID)
|
||||||
|
}
|
||||||
|
goto end
|
||||||
|
} else {
|
||||||
|
if app.Status != model.UserStatusNormal || app.DeletedAt != utils.DefaultTimeValue {
|
||||||
|
errCode = model.ErrCodeGeneralFailed
|
||||||
|
err = fmt.Errorf("很抱歉您的应用已失效!")
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
appKey := app.AppKey
|
||||||
|
signOrigin := fmt.Sprintf("%x", md5.Sum([]byte(utils.Int2Str(appID)+appKey+utils.Int64ToStr(timestamp))))
|
||||||
|
if strings.Compare(sign, signOrigin) != 0 {
|
||||||
|
errCode = model.ErrCodeOpenAPIParamErrSign
|
||||||
|
err = buildMethodParamSign()
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断app_id和sign匹配end
|
||||||
|
urls, _ = c.Input()
|
||||||
|
dataMap = utils.URLValues2Map(urls)
|
||||||
|
delete(dataMap, keyMethod)
|
||||||
|
delete(dataMap, keyTimestamp)
|
||||||
|
delete(dataMap, keySign)
|
||||||
|
parms = []reflect.Value{reflect.ValueOf(dataMap)}
|
||||||
|
if routerMap[method] == reflect.ValueOf(nil) {
|
||||||
|
errCode = model.ErrCodeOpenAPIParamErrMethod
|
||||||
|
err = buildMethodParamErr()
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("Begin API CallOpenAPI Method: %s, accessUUID:%s, sign:%s, ip:%s\n", method, accessID, sign, getRealRemoteIP(c.Ctx.Request))
|
||||||
|
if err == nil {
|
||||||
|
result = routerMap[method].Call(parms)
|
||||||
|
if result[2].Interface() != nil {
|
||||||
|
err = result[2].Interface().(error)
|
||||||
|
errCode = result[1].String()
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
goto success
|
||||||
|
} else {
|
||||||
|
callResult.Code = errCode
|
||||||
|
callResult.Desc = err.Error()
|
||||||
|
goto end
|
||||||
|
}
|
||||||
|
success:
|
||||||
|
{
|
||||||
|
c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
callResult.Code = model.ErrCodeSuccess
|
||||||
|
if len(result) > 0 {
|
||||||
|
callResult.Data = result[0].Interface()
|
||||||
|
}
|
||||||
|
c.Data["json"] = callResult
|
||||||
|
c.ServeJSON()
|
||||||
|
}
|
||||||
|
end:
|
||||||
|
{
|
||||||
|
callResult.Code = errCode
|
||||||
|
if err != nil {
|
||||||
|
callResult.Desc = err.Error()
|
||||||
|
}
|
||||||
|
c.Data["json"] = callResult
|
||||||
|
c.ServeJSON()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加打印机,一次最多50条
|
||||||
|
func (c *ApiController) AddPrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printers []*model.AddPrinterParam
|
||||||
|
appID int
|
||||||
|
)
|
||||||
|
if _, ok := dataMap["prints"].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr("prints_str_nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(dataMap["prints"].(string)), &printers); err != nil {
|
||||||
|
return buildParamErrCodeAndErr("prints_bind_fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range printers {
|
||||||
|
if v.PrintNo == "" {
|
||||||
|
return buildParamErrCodeAndErr("prints_no_nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
if err = cms.AddPrinter(appID, printers); err != nil {
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
return "", errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type QueryPrintList struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ApiController) QueryPrintList(dataMap map[string]interface{}) (data map[string]interface{}, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNo string
|
||||||
|
printKey string
|
||||||
|
status int64
|
||||||
|
isOnline int64
|
||||||
|
page int64
|
||||||
|
size int64
|
||||||
|
)
|
||||||
|
|
||||||
|
if printNoParam, ok := dataMap["print_no"].(string); !ok {
|
||||||
|
printNo = ""
|
||||||
|
} else {
|
||||||
|
printNo = printNoParam
|
||||||
|
}
|
||||||
|
if key, ok := dataMap["print_key"].(string); !ok {
|
||||||
|
printKey = ""
|
||||||
|
} else {
|
||||||
|
printKey = key
|
||||||
|
}
|
||||||
|
|
||||||
|
status = utils.Interface2Int64WithDefault(dataMap["status"], -9)
|
||||||
|
isOnline = utils.Interface2Int64WithDefault(dataMap["is_online"], -9)
|
||||||
|
page = utils.Interface2Int64WithDefault(dataMap["page"], 0)
|
||||||
|
size = utils.Interface2Int64WithDefault(dataMap["size"], 15)
|
||||||
|
|
||||||
|
list, count, err := cms.QueryPrintList(printNo, printKey, status, isOnline, page, size)
|
||||||
|
data = map[string]interface{}{
|
||||||
|
"printList": list,
|
||||||
|
"count": count,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除打印机绑定
|
||||||
|
func (c *ApiController) DelPrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNos []string
|
||||||
|
printNosStr string
|
||||||
|
appID int
|
||||||
|
storeId string
|
||||||
|
)
|
||||||
|
globals.SugarLogger.Debugf("Begin API DelPrinter data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
|
if _, ok := dataMap["print_nos"].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr("print_nos")
|
||||||
|
} else {
|
||||||
|
if printNosStr = dataMap["print_nos"].(string); printNosStr == "" {
|
||||||
|
return buildParamErrCodeAndErr("print_nos")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := dataMap["storeId"].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr("storeId")
|
||||||
|
}
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(printNosStr), &printNos); err != nil {
|
||||||
|
return buildParamErrCodeAndErr("print_nos")
|
||||||
|
}
|
||||||
|
for _, v := range printNos {
|
||||||
|
if v == "" {
|
||||||
|
return buildParamErrCodeAndErr("print_nos")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
if err = cms.DelPrinter(appID, printNos, storeId); err != nil {
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
return "", errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改打印机信息
|
||||||
|
func (c *ApiController) UpdatePrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNo string
|
||||||
|
name, sim, sound *string
|
||||||
|
volume *int
|
||||||
|
appID int
|
||||||
|
)
|
||||||
|
globals.SugarLogger.Debugf("Begin API UpdatePrinter data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
|
if _, ok := dataMap[keyPrintNo].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
} else {
|
||||||
|
if printNo = dataMap[keyPrintNo].(string); printNo == "" {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if nameStr, ok := dataMap[keyName].(string); !ok {
|
||||||
|
name = nil
|
||||||
|
} else {
|
||||||
|
name = &nameStr
|
||||||
|
}
|
||||||
|
if simStr, ok := dataMap[keySim].(string); !ok {
|
||||||
|
sim = nil
|
||||||
|
} else {
|
||||||
|
sim = &simStr
|
||||||
|
}
|
||||||
|
if soundStr, ok := dataMap[keySound].(string); !ok {
|
||||||
|
sound = nil
|
||||||
|
} else {
|
||||||
|
sound = &soundStr
|
||||||
|
}
|
||||||
|
if volumeStr, ok := dataMap[keyVolume].(string); !ok {
|
||||||
|
volume = nil
|
||||||
|
} else {
|
||||||
|
if volumeInt64, err2 := strconv.ParseInt(volumeStr, 10, 64); err2 == nil {
|
||||||
|
volumeInt := int(volumeInt64)
|
||||||
|
volume = &volumeInt
|
||||||
|
} else {
|
||||||
|
return buildParamErrCodeAndErr(keyVolume)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
if err = cms.UpdatePrinter(appID, printNo, name, sim, sound, volume); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("End API UpdatePrinter err: %v", err)
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
return "", errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//清空打印机队列
|
||||||
|
func (c *ApiController) DelPrinterSeq(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNo string
|
||||||
|
appID int
|
||||||
|
)
|
||||||
|
globals.SugarLogger.Debugf("Begin API DelPrinterSeq data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
|
if _, ok := dataMap[keyPrintNo].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
} else {
|
||||||
|
if printNo = dataMap[keyPrintNo].(string); printNo == "" {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
if err = cms.DelPrinterSeq(appID, printNo); err != nil {
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
return "", errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//发送打印消息
|
||||||
|
func (c *ApiController) DoPrint(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNo, content string
|
||||||
|
appID int
|
||||||
|
orderNo string
|
||||||
|
)
|
||||||
|
//globals.SugarLogger.Debugf("Begin API DoPrint data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
|
if _, ok := dataMap[keyPrintNo].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := dataMap[keyContent].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr(keyContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := dataMap[keyOrderNo].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr(keyOrderNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
msgID := time.Now().Format("20060102150405") + "_" + RandStringBytes(8)
|
||||||
|
printNo = dataMap[keyPrintNo].(string)
|
||||||
|
orderNo = dataMap[keyOrderNo].(string)
|
||||||
|
content = dataMap[keyContent].(string)
|
||||||
|
// 打印文件转结构体
|
||||||
|
contentMap := make(map[string]string)
|
||||||
|
if err := json.Unmarshal([]byte(content), &contentMap); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("json.Unmarshal 1 err := %v", err)
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
// 查询打印机设置
|
||||||
|
printSetting, err := dao.GetPrintSetting(printNo)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debugf("GetPrintSetting 2 err := %v", err)
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
printObj, err := dao.QueryUserPrinter("", printNo)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debugf("QueryUserPrinter 3 err := %v", err)
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户模板
|
||||||
|
printMsg, err := dao.MakePrintMsgOnTempVoice(contentMap, printSetting, printObj.UserId)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debugf("MakePrintMsgOnTempVoice 4 err := %v", err)
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
if printMsg == "" {
|
||||||
|
return "", model.ErrCodeGeneralFailed, errors.New("无打印数据")
|
||||||
|
}
|
||||||
|
content = printMsg
|
||||||
|
|
||||||
|
if err = cms.DoPrintMsg(appID, msgID, printNo, content, orderNo); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("DoPrint 5 err := %v", err)
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
return msgID, errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func RandStringBytes(n int) string {
|
||||||
|
b := make([]byte, n)
|
||||||
|
for i := range b {
|
||||||
|
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取某打印消息
|
||||||
|
func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (data map[string]interface{}, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
msgID string
|
||||||
|
appID int
|
||||||
|
)
|
||||||
|
globals.SugarLogger.Debugf("Begin API GetPrintMsg data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
|
if _, ok := dataMap[keyMsgID].(string); !ok {
|
||||||
|
return data, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
|
||||||
|
} else {
|
||||||
|
if msgID = dataMap[keyMsgID].(string); msgID == "" {
|
||||||
|
return data, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
if printMsg, err := cms.GetPrintMsg(appID, msgID); err != nil {
|
||||||
|
return data, model.ErrCodeGeneralFailed, err
|
||||||
|
} else if printMsg == nil {
|
||||||
|
return data, model.ErrCodeGeneralFailed, fmt.Errorf("未查询到该消息! msg_id: %v", msgID)
|
||||||
|
} else {
|
||||||
|
bf := bytes.NewBuffer([]byte{})
|
||||||
|
jsonEncoder := json.NewEncoder(bf)
|
||||||
|
jsonEncoder.SetEscapeHTML(false)
|
||||||
|
jsonEncoder.Encode(printMsg)
|
||||||
|
json.Unmarshal([]byte(bf.String()), &data)
|
||||||
|
return data, model.ErrCodeGeneralFailed, err
|
||||||
|
}
|
||||||
|
return data, errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询打印机状态
|
||||||
|
func (c *ApiController) GetPrinterStatus(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNo string
|
||||||
|
//appID int
|
||||||
|
)
|
||||||
|
globals.SugarLogger.Debugf("Begin API GetPrinterStatus data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
|
if _, ok := dataMap[keyPrintNo].(string); !ok {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
} else {
|
||||||
|
if printNo = dataMap[keyPrintNo].(string); printNo == "" {
|
||||||
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appID := utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
|
if status, err := cms.GetPrinterStatus(appID, printNo); err != nil {
|
||||||
|
return "", model.ErrCodeGeneralFailed, err
|
||||||
|
} else {
|
||||||
|
return utils.Int2Str(status), errCode, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRealRemoteIP(r *http.Request) (ip string) {
|
||||||
|
if r != nil {
|
||||||
|
ip = r.Header.Get("X-Forwarded-For")
|
||||||
|
if ip == "" {
|
||||||
|
ip = r.Header.Get("X-real-ip")
|
||||||
|
}
|
||||||
|
if ip == "" {
|
||||||
|
ip = strings.Split(r.RemoteAddr, ":")[0]
|
||||||
|
} else {
|
||||||
|
ip = strings.Split(ip, ",")[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ip
|
||||||
|
}
|
||||||
45
controllers/api_controller_ex.go
Normal file
45
controllers/api_controller_ex.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CallResult2 struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Desc string `json:"desc"`
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildParamRequiredErr(str []string) (err error) {
|
||||||
|
msg := "缺少参数["
|
||||||
|
for k, v := range str {
|
||||||
|
if k != 0 {
|
||||||
|
msg += "," + v
|
||||||
|
} else {
|
||||||
|
msg += v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg += "],请传入正确的值!"
|
||||||
|
return fmt.Errorf(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildParamErrCodeAndErr(str string) (data, errCode string, err error) {
|
||||||
|
return data, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", str)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildParamErr(str string) (err error) {
|
||||||
|
return fmt.Errorf("参数[%s]错误,请传入正确的值!", str)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildMethodParamSign() (err error) {
|
||||||
|
return fmt.Errorf("参数['sign']校验失败,请传入正确的值!")
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildMethodParamErr() (err error) {
|
||||||
|
return fmt.Errorf("参数['method']错误,请传入正确的值!")
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildTimestampParamErr() (err error) {
|
||||||
|
return fmt.Errorf("参数['timestamp']和服务器时间差距过大,请传入正确的值!")
|
||||||
|
}
|
||||||
@@ -307,8 +307,9 @@ func (c *EventController) UploadAudio() {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
io.Copy(f, file)
|
io.Copy(f, file)
|
||||||
|
//c.SaveToFile("rsmAudio", filePath+fileName)
|
||||||
return &model.ImMessageRecord{
|
return &model.ImMessageRecord{
|
||||||
|
//Content: "https://www.jxcs.net/jxdata/cthrgw/dist/audio/" + timeStr + "/" + fileName,
|
||||||
Content: "https://www.jxcs.net/audio/" + timeStr + "/" + fileName,
|
Content: "https://www.jxcs.net/audio/" + timeStr + "/" + fileName,
|
||||||
}, "", err
|
}, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func (c *JobController) PublishJob() {
|
|||||||
c.callPublishJob(func(params *tJobPublishJobParams) (retVal interface{}, errCode string, err error) {
|
c.callPublishJob(func(params *tJobPublishJobParams) (retVal interface{}, errCode string, err error) {
|
||||||
var job *model.JobExt
|
var job *model.JobExt
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &job); err == nil {
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &job); err == nil {
|
||||||
errCode, err = cms.PublishJob(params.Ctx, job)
|
_, errCode, err = cms.PublishJob(params.Ctx, job)
|
||||||
}
|
}
|
||||||
return retVal, errCode, err
|
return retVal, errCode, err
|
||||||
})
|
})
|
||||||
@@ -546,8 +546,8 @@ func (c *JobController) RefreshJdDelivery() {
|
|||||||
// @router /TempJob [post]
|
// @router /TempJob [post]
|
||||||
func (c *JobController) TempJob() {
|
func (c *JobController) TempJob() {
|
||||||
c.callTempJob(func(params *tJobTempJobParams) (retVal interface{}, errCode string, err error) {
|
c.callTempJob(func(params *tJobTempJobParams) (retVal interface{}, errCode string, err error) {
|
||||||
//cms.TempJob()
|
err = cms.TempJob()
|
||||||
cms.TestTemp()
|
//cms.TestTemp()
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -561,7 +561,7 @@ func (c *JobController) TempJob() {
|
|||||||
// @router /TempJobTest [post]
|
// @router /TempJobTest [post]
|
||||||
func (c *JobController) TempJobTest() {
|
func (c *JobController) TempJobTest() {
|
||||||
c.callTempJobTest(func(params *tJobTempJobTestParams) (retVal interface{}, errCode string, err error) {
|
c.callTempJobTest(func(params *tJobTempJobTestParams) (retVal interface{}, errCode string, err error) {
|
||||||
cms.TestTemp2(params.Data)
|
cms.TestTemp2()
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,18 +11,41 @@ type OrderController struct {
|
|||||||
beego.Controller
|
beego.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pay 订单支付
|
||||||
// @Title 支付
|
// @Title 支付
|
||||||
// @Description 支付
|
// @Description 支付
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param orderID formData string true "订单号"
|
// @Param orderID formData string true "订单号"
|
||||||
// @Param payType formData int true "支付平台类型"
|
// @Param payType formData int true "支付平台类型"
|
||||||
// @Param vendorPayType formData string true "平台支付类型"
|
// @Param vendorPayType formData string true "平台支付类型"
|
||||||
|
// @Param orderType formData string true "订单类型member(会员),express快递,recharge充值,telephoneBill充话费"
|
||||||
|
// @Param appId formData string true "appId"
|
||||||
|
// @Param isChoose formData int true "-1:未选中余额抵消 1:余额抵消"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /Pay [post]
|
// @router /Pay [post]
|
||||||
func (c *OrderController) Pay() {
|
func (c *OrderController) Pay() {
|
||||||
c.callPay(func(params *tOrderPayParams) (retVal interface{}, errCode string, err error) {
|
c.callPay(func(params *tOrderPayParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.Pay(params.Ctx, params.OrderID, params.PayType, params.VendorPayType)
|
retVal, err = cms.Pay(params.Ctx, params.OrderID, params.PayType, params.VendorPayType, params.AppId, params.IsChoose)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 余额支付
|
||||||
|
// @Description 支付
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param orderID formData string true "订单号"
|
||||||
|
// @Param payType formData int true "支付平台类型"
|
||||||
|
// @Param vendorPayType formData string true "平台支付类型"
|
||||||
|
// @Param orderType formData string true "订单类型member(会员),express快递,recharge充值"
|
||||||
|
// @Param appId formData string true "appId"
|
||||||
|
// @Param isChoose formData int true "-1:未选中余额抵消 1:余额抵消"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /PayByBalance [post]
|
||||||
|
func (c *OrderController) PayByBalance() {
|
||||||
|
c.callPayByBalance(func(params *tOrderPayByBalanceParams) (retVal interface{}, errMsg string, err error) {
|
||||||
|
retVal, _, err = cms.PayByBalance(params.Ctx, params.OrderID, params.IsChoose, params.PayType, params.VendorPayType, params.AppId)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -47,17 +70,19 @@ func (c *OrderController) Cash() {
|
|||||||
// @Description 创建订单
|
// @Description 创建订单
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param type formData int true "支付类型/账单类型"
|
// @Param type formData int true "支付类型/账单类型"
|
||||||
// @Param orderType formData int true "订单类型,1为发任务,2为冲会员,3为发快递"
|
// @Param orderType formData int true "订单类型,1为发任务,2为冲会员,3为发快递,6-需要充值到余额购买的方式,7-话费充值"
|
||||||
// @Param way formData string true "认证方式"
|
// @Param way formData string true "认证方式"
|
||||||
// @Param price formData int true "支付金额"
|
// @Param price formData int true "支付金额"
|
||||||
// @Param lng formData float64 true "经纬度"
|
// @Param lng formData float64 true "经纬度"
|
||||||
// @Param lat formData float64 true "经纬度"
|
// @Param lat formData float64 true "经纬度"
|
||||||
|
// @Param mobile formData string false "充值电话"
|
||||||
|
// @Param flowCode formData string false "业务代码"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /CreateOrder [post]
|
// @router /CreateOrder [post]
|
||||||
func (c *OrderController) CreateOrder() {
|
func (c *OrderController) CreateOrder() {
|
||||||
c.callCreateOrder(func(params *tOrderCreateOrderParams) (retVal interface{}, errCode string, err error) {
|
c.callCreateOrder(func(params *tOrderCreateOrderParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, errCode, err = cms.CreateOrder(params.Ctx, params.Type, params.OrderType, params.Way, params.Price, params.Lng, params.Lat)
|
retVal, errCode, err = cms.CreateOrder(params.Ctx, params.Type, params.OrderType, params.Way, params.Price, params.Lng, params.Lat, params.Mobile, params.FlowCode)
|
||||||
return retVal, errCode, err
|
return retVal, errCode, err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
265
controllers/q_bida.go
Normal file
265
controllers/q_bida.go
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
bida "git.rosy.net.cn/baseapi/platformapi/q_bida"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
bidaServer "git.rosy.net.cn/jx-callback/business/q_bida"
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
type QBiDaExpressController struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryExpressPrice 查询物流费
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 查询快递费
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param promiseTimeType formData int false "快递时效产品"
|
||||||
|
// @Param deliveryType formData int false "产品类型"
|
||||||
|
// @Param goodsValue formData float64 false "保价金额"
|
||||||
|
// @Param receiveAddress formData string true "收件人地址"
|
||||||
|
// @Param sendAddress formData string true "寄件人地址"
|
||||||
|
// @Param type formData int false "快递公司"
|
||||||
|
// @Param weight formData int true "重量kg"
|
||||||
|
// @Param length formData int false "所有包裹累计长"
|
||||||
|
// @Param width formData int false "所有包裹累计宽"
|
||||||
|
// @Param height formData int false "所有包裹累计高"
|
||||||
|
// @Param sendPhone formData string true "寄件人手机号"
|
||||||
|
// @Param channelType formData int true "渠道类型(1-快递,2-物流,3-国际物流,4-整车)"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /QueryExpressPrice [post]
|
||||||
|
func (c *QBiDaExpressController) QueryExpressPrice() {
|
||||||
|
c.callQueryExpressPrice(func(params *tExpressQueryExpressPriceParams) (interface{}, string, error) {
|
||||||
|
param := &bida.GetExpressPriceReq{
|
||||||
|
PromiseTimeType: params.PromiseTimeType,
|
||||||
|
DeliveryType: params.DeliveryType,
|
||||||
|
GoodsValue: params.GoodsValue,
|
||||||
|
ReceiveAddress: params.ReceiveAddress,
|
||||||
|
SendAddress: params.SendAddress,
|
||||||
|
Type: params.Type,
|
||||||
|
Weight: params.Weight,
|
||||||
|
Length: params.Length,
|
||||||
|
Height: params.Height,
|
||||||
|
Width: params.Width,
|
||||||
|
SendPhone: params.SendPhone,
|
||||||
|
ChannelType: params.ChannelType,
|
||||||
|
}
|
||||||
|
result, err := bidaServer.QueryExpressPrice(param)
|
||||||
|
for _, v := range result {
|
||||||
|
fmt.Println(v.Data.TypeName, v.Data.Type, v.Data.ChannelFee)
|
||||||
|
}
|
||||||
|
return result, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWayOrder 下单
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 下单
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param promiseTimeType formData int false "快递时效产品"
|
||||||
|
// @Param deliveryType formData int false "产品类型"
|
||||||
|
// @Param goods formData string true "商品名称"
|
||||||
|
// @Param guaranteeValueAmount formData float64 false "保价金额"
|
||||||
|
// @Param weight formData int true "重量kg"
|
||||||
|
// @Param length formData int false "所有包裹累计长"
|
||||||
|
// @Param width formData int false "所有包裹累计宽"
|
||||||
|
// @Param height formData int false "所有包裹累计高"
|
||||||
|
// @Param orderSendTime formData string false "预约时间"
|
||||||
|
// @Param packageNum formData int true "包裹数量"
|
||||||
|
// @Param receiveAddress formData string true "收件人地址"
|
||||||
|
// @Param receiveName formData string true "收件人姓名"
|
||||||
|
// @Param receivePhone formData string true "收件人手机号"
|
||||||
|
// @Param remark formData string false "运单备注"
|
||||||
|
// @Param senderAddress formData string true "寄件人地址"
|
||||||
|
// @Param senderName formData string true "寄件人姓名"
|
||||||
|
// @Param senderPhone formData string true "寄件人手机号"
|
||||||
|
// @Param thirdPlatform formData int false "第三方平台"
|
||||||
|
// @Param type formData int true "快递公司"
|
||||||
|
// @Param receiveAddressId formData int64 true "收件人地址Id"
|
||||||
|
// @Param senderAddressId formData int64 true "寄件人地址Id"
|
||||||
|
// @Param channelType formData int true "渠道类型(1-快递,2-物流,3-国际物流,4-整车)"
|
||||||
|
// @Param images formData string false "物品图片多个用逗号隔开"
|
||||||
|
// @Param channelFee formData float64 true "渠道价"
|
||||||
|
// @Param bulk formData int false "泡比"
|
||||||
|
// @Param serviceCharge formData float64 false "服务费"
|
||||||
|
// @Param guarantFee formData float64 false "保价"
|
||||||
|
// @Param originalFee formData float64 false "原价"
|
||||||
|
// @Param increment formData float64 false "物流"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /CreateWayOrder [post]
|
||||||
|
func (c *QBiDaExpressController) CreateWayOrder() {
|
||||||
|
c.callCreateWayOrder(func(params *tExpressCreateWayOrderParams) (interface{}, string, error) {
|
||||||
|
param := &model.MakeOrderParamReq{
|
||||||
|
PromiseTimeType: params.PromiseTimeType,
|
||||||
|
DeliveryType: params.DeliveryType,
|
||||||
|
Goods: params.Goods,
|
||||||
|
GuaranteeValueAmount: params.GuaranteeValueAmount,
|
||||||
|
Weight: params.Weight,
|
||||||
|
Length: params.Length,
|
||||||
|
Height: params.Height,
|
||||||
|
Width: params.Width,
|
||||||
|
OrderSendTime: params.OrderSendTime,
|
||||||
|
PackageNum: params.PackageNum,
|
||||||
|
ReceiveAddress: params.ReceiveAddress,
|
||||||
|
ReceiveName: params.ReceiveName,
|
||||||
|
ReceivePhone: params.ReceivePhone,
|
||||||
|
Remark: params.Remark,
|
||||||
|
SenderAddress: params.SenderAddress,
|
||||||
|
SenderName: params.SenderName,
|
||||||
|
SenderPhone: params.SenderPhone,
|
||||||
|
ThirdPlatform: params.ThirdPlatform,
|
||||||
|
Type: params.Type,
|
||||||
|
ReceiveAddressId: int64(params.ReceiveAddressId),
|
||||||
|
SenderAddressId: int64(params.SenderAddressId),
|
||||||
|
ChannelType: params.ChannelType,
|
||||||
|
Images: params.Images,
|
||||||
|
ChannelFee: params.ChannelFee,
|
||||||
|
Bulk: utils.Int2Float64(params.Bulk),
|
||||||
|
ServiceCharge: params.ServiceCharge,
|
||||||
|
GuarantFee: params.GuarantFee,
|
||||||
|
OriginalFee: params.OriginalFee,
|
||||||
|
Increment: params.Increment,
|
||||||
|
}
|
||||||
|
|
||||||
|
order, err := bidaServer.CreateWayOrder(params.Ctx, param, params.Ctx.GetUserID())
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
return order, "", nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// pay 取消运单
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 取消运单
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param genre formData int true "1取消2关闭"
|
||||||
|
// @Param orderNo formData string true "订单编号"
|
||||||
|
// @Param type formData int true "快递公司"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /CancelWayVendorOrder [post]
|
||||||
|
func (c *QBiDaExpressController) CancelWayVendorOrder() {
|
||||||
|
c.callCancelWayVendorOrder(func(params *tExpressCancelWayVendorOrderParams) (interface{}, string, error) {
|
||||||
|
cancel := &bida.CancelOrderReq{
|
||||||
|
Genre: params.Genre,
|
||||||
|
OrderNo: params.OrderNo,
|
||||||
|
Type: params.Type,
|
||||||
|
}
|
||||||
|
code, err := bidaServer.CancelWayOrder(params.Ctx, params.Ctx.GetUserID(), cancel)
|
||||||
|
if err != nil {
|
||||||
|
return code, "", err
|
||||||
|
}
|
||||||
|
return code, "", nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// pay 获取用户订单列表QueryUserOrderList
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 获取用户订单列表
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param expressType formData int false "就是type快递公司"
|
||||||
|
// @Param orderStatus formData int false "订单状态"
|
||||||
|
// @Param orderNo formData string false "订单号码"
|
||||||
|
// @Param pageNum formData int true "页码"
|
||||||
|
// @Param pageSize formData int true "页数"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /QueryUserOrderList [post]
|
||||||
|
func (c *QBiDaExpressController) QueryUserOrderList() {
|
||||||
|
c.callQueryUserOrderList(func(params *tExpressQueryUserOrderListParams) (interface{}, string, error) {
|
||||||
|
result, count, err := bidaServer.QueryUserOrderList(params.Ctx.GetUserID(), params.ExpressType, params.OrderStatus, params.PageNum, params.PageSize, params.OrderNo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[string]interface{}{"result": result, "count": count}, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrderDetail 查询订单详情
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 获取订单详情
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param expressType formData int true "就是type快递公司"
|
||||||
|
// @Param orderNo formData string true "订单Id,三方Id"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetOrderDetail [post]
|
||||||
|
func (c *QBiDaExpressController) GetOrderDetail() {
|
||||||
|
c.callGetOrderDetail(func(params *tExpressGetOrderDetailParams) (interface{}, string, error) {
|
||||||
|
result, err := bidaServer.QueryOrderDetail(params.ExpressType, params.OrderNo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
return result, "", nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrderList 管理系统获取订单详情
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 管理系统获取订单详情
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param expressType formData int false "就是type快递公司"
|
||||||
|
// @Param orderNo formData string false "订单Id,三方Id"
|
||||||
|
// @Param orderStatus formData int false "订单状态"
|
||||||
|
// @Param pageNum formData int true "页码"
|
||||||
|
// @Param pageSize formData int true "页数"
|
||||||
|
// @Param startTime formData string true "开始时间"
|
||||||
|
// @Param endTime formData string true "结束时间"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetOrderList [post]
|
||||||
|
func (c *QBiDaExpressController) GetOrderList() {
|
||||||
|
c.callGetOrderList(func(params *tExpressGetOrderListParams) (interface{}, string, error) {
|
||||||
|
listParam := &model.OrderListReq{
|
||||||
|
ExpressType: params.ExpressType,
|
||||||
|
OrderNo: params.OrderNo,
|
||||||
|
OrderStatus: params.OrderStatus,
|
||||||
|
PageNum: params.PageNum,
|
||||||
|
PageSize: params.PageSize,
|
||||||
|
StartTime: utils.Str2Time(params.StartTime),
|
||||||
|
EndTime: utils.Str2Time(params.EndTime),
|
||||||
|
}
|
||||||
|
result, count, err := bidaServer.ManagerGetOrderList(listParam)
|
||||||
|
data := make(map[string]interface{}, 2)
|
||||||
|
data["result"] = result
|
||||||
|
data["count"] = count
|
||||||
|
return data, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrder 删除订单
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 删除未支付订单,已支付订单一个星期后才能删除
|
||||||
|
// @Param token header string true "管理员token"
|
||||||
|
// @Param localOrderId formData string true "本地订单"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /DeleteOrder [post]
|
||||||
|
func (c *QBiDaExpressController) DeleteOrder() {
|
||||||
|
c.callDeleteOrder(func(params *tExpressDeleteOrderParams) (interface{}, string, error) {
|
||||||
|
count, err := bidaServer.DeleteOrderByLocalId(params.Ctx.GetUserID(), params.LocalOrderId)
|
||||||
|
return count, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TryAgainOrderByOldOrder 用户再来一单
|
||||||
|
// @Title Q必达
|
||||||
|
// @Description 再来一单
|
||||||
|
// @Param token header string true "用户token"
|
||||||
|
// @Param oldNo formData string true "旧的订单Id"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /TryAgainOrderByOldOrder [post]
|
||||||
|
func (c *QBiDaExpressController) TryAgainOrderByOldOrder() {
|
||||||
|
c.callTryAgainOrderByOldOrder(func(params *tExpressTryAgainOrderByOldOrderParams) (interface{}, string, error) {
|
||||||
|
newOrder, err := bidaServer.TryAgainOrder(params.Ctx, params.OldNo)
|
||||||
|
return newOrder, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
69
controllers/recharge_callback.go
Normal file
69
controllers/recharge_callback.go
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
beego "github.com/astaxie/beego/adapter"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RechargeController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallBackMsg struct {
|
||||||
|
Sign string `json:"sign"` // 签名:大写( md5( md5(密码)+ 平台订单号+秘钥 ) )
|
||||||
|
Msg string `json:"msg"` // 响应结果描述
|
||||||
|
OrderNumber string `json:"order_number "` // 平台订单号
|
||||||
|
UserOrdernum string `json:"user_ordernum"` // 商户订单号
|
||||||
|
OrderStatus string `json:"order_status"` // 状态:0:未提交,1:充值中,2:已充值,-1:失败
|
||||||
|
Mobile string `json:"mobile"` // 电话
|
||||||
|
Ctime string `json:"ctime"` // ctime
|
||||||
|
Voucher string `json:"voucher"` // 透传流水号
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *RechargeController) Msg() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
data, err := ioutil.ReadAll(getUsefulRequest2(c.Ctx).Body)
|
||||||
|
if err != nil {
|
||||||
|
c.Abort("404")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
values, err := utils.HTTPBody2Values(data, false)
|
||||||
|
if err != nil {
|
||||||
|
c.Abort("404")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mapData := utils.URLValues2Map(values)
|
||||||
|
resultData := CallBackMsg{}
|
||||||
|
if err := utils.Map2StructByJson(mapData, &resultData, false); err != nil {
|
||||||
|
c.Abort("404")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if resultData.OrderStatus == "0" || resultData.OrderStatus == "1" {
|
||||||
|
c.Data["json"] = "success"
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 获取平台订单
|
||||||
|
order := &model.Order{
|
||||||
|
OrderID: resultData.UserOrdernum,
|
||||||
|
}
|
||||||
|
if err = dao.GetEntity(dao.GetDB(), order, "OrderID"); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("本地加载订单错误,请查询:%s", err)
|
||||||
|
c.Abort("404")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
order.RechargeStatus = utils.Str2Int(resultData.OrderStatus)
|
||||||
|
|
||||||
|
dao.UpdateEntity(dao.GetDB(), order, "RechargeStatus")
|
||||||
|
c.Data["json"] = "success"
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
105
controllers/recharge_controller.go
Normal file
105
controllers/recharge_controller.go
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
beego "github.com/astaxie/beego/adapter"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RechargeManagerController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserRecharge 用户查询充值记录
|
||||||
|
// @Title 分页查询用户充值列表
|
||||||
|
// @Description 分页查询用户充值列表
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param page formData int true "页码"
|
||||||
|
// @Param pageSize formData int true "页数"
|
||||||
|
// @Param mobile formData string false "电话"
|
||||||
|
// @Param orderId formData string false "订单号"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetUserRecharge [post]
|
||||||
|
func (c *RechargeManagerController) GetUserRecharge() {
|
||||||
|
c.callGetUserRecharge(func(params *tRechargeGetUserRechargeParams) (interface{}, string, error) {
|
||||||
|
result, count, err := cms.QueryUserRecharge([]string{params.Ctx.GetUserID()}, params.Mobile, params.OrderId, params.Page, params.PageSize, "", "", 0)
|
||||||
|
userRecharge := make(map[string]interface{}, 2)
|
||||||
|
userRecharge["data"] = result
|
||||||
|
userRecharge["count"] = count
|
||||||
|
return userRecharge, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRechargeOrderDetail 订单详情查询
|
||||||
|
// @Title 订单详情查询
|
||||||
|
// @Description 订单详情查询
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param orderId formData string true "订单号"
|
||||||
|
// @Param mobile formData string true "手机号"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetRechargeOrderDetail [get]
|
||||||
|
func (c *RechargeManagerController) GetRechargeOrderDetail() {
|
||||||
|
c.callGetRechargeOrderDetail(func(params *tRechargeGetRechargeOrderDetailParams) (interface{}, string, error) {
|
||||||
|
result, err := cms.QueryUserOrderDetail(params.OrderId, params.Mobile)
|
||||||
|
return result, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SystemQueryRechargeList 管理系统获取订单详情
|
||||||
|
// @Title 管理系统获取订单详情
|
||||||
|
// @Description 管理系统获取订单详情
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param orderId formData string false "订单号"
|
||||||
|
// @Param mobile formData string false "手机号"
|
||||||
|
// @Param rechargeStatus formData int false "充值状态 0-未提交,3-等待待充值(本地) 1:充值中(三方),2:已充值,-1:失败(三方)"
|
||||||
|
// @Param page formData int true "页码"
|
||||||
|
// @Param pageSize formData int true "页数"
|
||||||
|
// @Param startTime formData string true "开始时间"
|
||||||
|
// @Param endTime formData string true "结束时间"
|
||||||
|
// @Param userName formData string false "用户名"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /SystemQueryRechargeList [post]
|
||||||
|
func (c *RechargeManagerController) SystemQueryRechargeList() {
|
||||||
|
c.callSystemQueryRechargeList(func(params *tRechargeSystemQueryRechargeListParams) (interface{}, string, error) {
|
||||||
|
userIdList := make([]string, 0, 0)
|
||||||
|
// 根据用户获取用户id
|
||||||
|
if params.UserName != "" {
|
||||||
|
userList, _, err := dao.GetUsers(dao.GetDB(), 0, params.UserName, "", nil, nil, nil, 0, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
if len(userList) == 0 {
|
||||||
|
return nil, "", errors.New(fmt.Sprintf("未查询到此用户:[%s]", params.UserName))
|
||||||
|
}
|
||||||
|
for _, v := range userList {
|
||||||
|
userIdList = append(userIdList, v.UserID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result, count, err := cms.QueryUserRecharge(userIdList, params.Mobile, params.OrderId, params.Page, params.PageSize, params.StartTime, params.EndTime, params.RechargeStatus)
|
||||||
|
userRecharge := make(map[string]interface{}, 2)
|
||||||
|
userRecharge["data"] = result
|
||||||
|
userRecharge["count"] = count
|
||||||
|
return userRecharge, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryAccountBill 查询当前账号余额
|
||||||
|
// @Title 查询当前账号余额
|
||||||
|
// @Description 查询当前账号余额
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /QueryAccountBill [get]
|
||||||
|
func (c *RechargeManagerController) QueryAccountBill() {
|
||||||
|
c.callQueryAccountBill(func(params *tRechargeQueryAccountBillParams) (interface{}, string, error) {
|
||||||
|
balance, err := api.TelephoneAPI.QueryAccountBill()
|
||||||
|
return balance, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -24,10 +24,15 @@ func (c *TongLianController) Msg() {
|
|||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
call, err := api.TLpayAPI.GetCallbackMsg(getUsefulRequest2(c.Ctx))
|
call, err := api.TLpayAPI.GetCallbackMsg(getUsefulRequest2(c.Ctx))
|
||||||
globals.SugarLogger.Debugf("tonglianapi callback callbackResponse:%s", utils.Format4Output(call, true))
|
globals.SugarLogger.Debugf("tonglianapi callback callbackResponse:%s", utils.Format4Output(call, true))
|
||||||
if err == nil {
|
if err != nil {
|
||||||
err = financial.OnTLPayCallback(call)
|
c.Abort("404")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
c.Data["json"] = call
|
if err = financial.OnTLPayCallback(call); err != nil {
|
||||||
|
c.Abort("404")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Data["json"] = "success"
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
} else {
|
} else {
|
||||||
c.Abort("404")
|
c.Abort("404")
|
||||||
|
|||||||
@@ -113,12 +113,13 @@ func (c *User2Controller) GetUser() {
|
|||||||
// @Param consigneeMobile formData string true "收货人手机"
|
// @Param consigneeMobile formData string true "收货人手机"
|
||||||
// @Param address formData string false "地址(区县以下,门牌号以上的地址信息)"
|
// @Param address formData string false "地址(区县以下,门牌号以上的地址信息)"
|
||||||
// @Param detailAddress formData string false "门牌号"
|
// @Param detailAddress formData string false "门牌号"
|
||||||
// @Param lng formData float64 true "经度"
|
// @Param lng formData float64 false "经度"
|
||||||
// @Param lat formData float64 true "纬度"
|
// @Param lat formData float64 false "纬度"
|
||||||
// @Param tag formData string false "标签"
|
// @Param tag formData string false "标签"
|
||||||
// @Param remark formData string false "备注"
|
// @Param remark formData string false "备注"
|
||||||
// @Param isDefault formData int false "是否是默认"
|
// @Param isDefault formData int false "是否是默认"
|
||||||
// @Param type formData int false "1为寄件人,2为取件人(收货人)"
|
// @Param type formData int false "1为寄件人,2为取件人(收货人)"
|
||||||
|
// @Param autoAddress formData string false "详细地址"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /AddMyDeliveryAddress [post]
|
// @router /AddMyDeliveryAddress [post]
|
||||||
@@ -139,6 +140,7 @@ func (c *User2Controller) AddMyDeliveryAddress() {
|
|||||||
Remark: params.Remark,
|
Remark: params.Remark,
|
||||||
IsDefault: int8(params.IsDefault),
|
IsDefault: int8(params.IsDefault),
|
||||||
Type: params.Type,
|
Type: params.Type,
|
||||||
|
AutoAddress: params.AutoAddress,
|
||||||
}
|
}
|
||||||
retVal, err = cms.AddMyDeliveryAddress(params.Ctx, address)
|
retVal, err = cms.AddMyDeliveryAddress(params.Ctx, address)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
|
|||||||
32
controllers/user_balance.go
Normal file
32
controllers/user_balance.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserBalanceController struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
var DefaultMobile = map[string]string{"18048531223": "ok", "15729837802": "ok"}
|
||||||
|
|
||||||
|
// UpdateUserBalance
|
||||||
|
// @Title 修改用户账户余额
|
||||||
|
// @Description 用户余额
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param phone formData string true "发起修改人电话"
|
||||||
|
// @Param userID formData string true "被修用户Id"
|
||||||
|
// @Param money formData int false "修改后金额"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /UpdateUserBalance [post]
|
||||||
|
func (c *UserBalanceController) UpdateUserBalance() {
|
||||||
|
c.callUpdateUserBalance(func(params *tBalanceUpdateUserBalanceParams) (interface{}, string, error) {
|
||||||
|
if DefaultMobile[params.Phone] != "ok" {
|
||||||
|
return nil, "", errors.New("此用户不能修改用户金额")
|
||||||
|
}
|
||||||
|
return nil, "", dao.UpdateUserBill(params.UserID, params.Money)
|
||||||
|
})
|
||||||
|
}
|
||||||
136
controllers/withdrawal_record.go
Normal file
136
controllers/withdrawal_record.go
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
withdreawal "git.rosy.net.cn/jx-callback/business/q_bida"
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WithdrawalRecordController struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddWithdrawalRecord
|
||||||
|
// @Title 用户发起提现申请
|
||||||
|
// @Description 提现申请
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param withdrawalMoney formData int true "提现金额"
|
||||||
|
// @Param alipayAccount formData string true "支付宝绑定账号[邮箱/电话]"
|
||||||
|
// @Param alipayName formData string true "真是姓名"
|
||||||
|
// @Param lng formData float64 true "经度"
|
||||||
|
// @Param lat formData float64 true "纬度"
|
||||||
|
// @Param cityCode formData int true "城市code"
|
||||||
|
// @Param districtCode formData int true "省code"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /AddWithdrawalRecord [post]
|
||||||
|
func (c *WithdrawalRecordController) AddWithdrawalRecord() {
|
||||||
|
c.callAddWithdrawalRecord(func(params *tWithdrawalAddWithdrawalRecordParams) (interface{}, string, error) {
|
||||||
|
param := &model.AddWithdrawalRecordReq{
|
||||||
|
WithdrawalMoney: params.WithdrawalMoney,
|
||||||
|
AlipayAccount: params.AlipayAccount,
|
||||||
|
AlipayName: params.AlipayName,
|
||||||
|
Lng: params.Lng,
|
||||||
|
Lat: params.Lat,
|
||||||
|
CityCode: params.CityCode,
|
||||||
|
DistrictCode: params.DistrictCode,
|
||||||
|
}
|
||||||
|
err := withdreawal.AddUserWithdrawal(params.Ctx, param)
|
||||||
|
return nil, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteWithdrawalRecord
|
||||||
|
// @Title 取消或者删除提现生情
|
||||||
|
// @Description 提现申请
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param id formData int64 true "数据主键Id"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /DeleteWithdrawalRecord [post]
|
||||||
|
func (c *WithdrawalRecordController) DeleteWithdrawalRecord() {
|
||||||
|
c.callDeleteWithdrawalRecord(func(params *tWithdrawalDeleteWithdrawalRecordParams) (interface{}, string, error) {
|
||||||
|
err := withdreawal.DeleteOrder(params.Ctx.GetUserID(), params.Id)
|
||||||
|
return nil, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWithdrawalRecord
|
||||||
|
// 用户查询申请列表
|
||||||
|
// @Title 查询申请列表
|
||||||
|
// @Description 提现申请
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param status formData int true "申请订单状态"
|
||||||
|
// @Param pageSize formData int true "页数"
|
||||||
|
// @Param pageNum formData int true "页码"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetWithdrawalRecord [post]
|
||||||
|
func (c *WithdrawalRecordController) GetWithdrawalRecord() {
|
||||||
|
c.callGetWithdrawalRecord(func(params *tWithdrawalGetWithdrawalRecordParams) (interface{}, string, error) {
|
||||||
|
result, err := withdreawal.GetOrderListByStatus(params.Ctx.GetUserID(), params.Status, params.PageSize, params.PageNum)
|
||||||
|
return result, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWithdrawalList
|
||||||
|
// 管理系统查询列表
|
||||||
|
// @Title 查询申请列表
|
||||||
|
// @Description 提现申请
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param pageSize formData int true "页数"
|
||||||
|
// @Param pageNum formData int true "页码"
|
||||||
|
// @Param userName formData string false "用户昵称"
|
||||||
|
// @Param userId formData string false "用户id"
|
||||||
|
// @Param orderId formData string false "订单Id"
|
||||||
|
// @Param startTime formData string false "开始时间"
|
||||||
|
// @Param endTime formData string false "结束时间"
|
||||||
|
// @Param phone formData string false "电话"
|
||||||
|
// @Param orderStatus formData int false "订单状态"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetWithdrawalList [post]
|
||||||
|
func (c *WithdrawalRecordController) GetWithdrawalList() {
|
||||||
|
c.callGetWithdrawalList(func(params *tWithdrawalGetWithdrawalListParams) (interface{}, string, error) {
|
||||||
|
data, count, err := withdreawal.GetUserWithdrawalList(&model.OrderListParam{
|
||||||
|
PageSize: params.PageSize,
|
||||||
|
PageNum: params.PageNum,
|
||||||
|
UserId: params.UserId,
|
||||||
|
UserName: params.UserName,
|
||||||
|
OrderId: params.OrderId,
|
||||||
|
Phone: params.Phone,
|
||||||
|
OrderStatus: params.OrderStatus,
|
||||||
|
StartTime: params.StartTime,
|
||||||
|
EndTime: params.EndTime,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[string]interface{}{"data": data, "count": count}, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExamineWithdrawalOrder
|
||||||
|
// 管理员审核提现申请
|
||||||
|
// @Title 审核提现申请
|
||||||
|
// @Description 审核提现申请
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param phone formData string true "当前审核人员电话号码"
|
||||||
|
// @Param orderId formData string true "被审核订单Id"
|
||||||
|
// @Param examineStatus formData int true "1-通过"
|
||||||
|
// @Param remark formData string false "不通过原因"
|
||||||
|
// @Param userId formData string false "提现人员Id"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /ExamineWithdrawalOrder [post]
|
||||||
|
func (c *WithdrawalRecordController) ExamineWithdrawalOrder() {
|
||||||
|
c.callExamineWithdrawalOrder(func(params *tWithdrawalExamineWithdrawalOrderParams) (interface{}, string, error) {
|
||||||
|
if DefaultMobile[params.Phone] != "ok" {
|
||||||
|
return nil, "", errors.New("当前用户不具备操作权限,请联系管理员")
|
||||||
|
}
|
||||||
|
err := withdreawal.ManagerExamineWithdrawal(params.UserId, params.OrderId, params.ExamineStatus, params.Phone, params.Remark)
|
||||||
|
return nil, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdunionapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdunionapi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/pddapi"
|
"git.rosy.net.cn/baseapi/platformapi/pddapi"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/q_bida"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/recharge_phone_bill"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/tbunionapi"
|
"git.rosy.net.cn/baseapi/platformapi/tbunionapi"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
@@ -14,8 +16,6 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtmemberapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtmemberapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/unipushapi"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/aliupcapi"
|
"git.rosy.net.cn/baseapi/platformapi/aliupcapi"
|
||||||
@@ -80,10 +80,13 @@ var (
|
|||||||
AliUpcAPI *aliupcapi.API //阿里商品条码查询api
|
AliUpcAPI *aliupcapi.API //阿里商品条码查询api
|
||||||
EjyAPI *ejyapi.API //易加油
|
EjyAPI *ejyapi.API //易加油
|
||||||
|
|
||||||
PushAPI *unipushapi.API
|
//PushAPI *unipushapi.API
|
||||||
|
|
||||||
Cacher cache.ICacher
|
Cacher cache.ICacher
|
||||||
SMSClient *aliyunsmsclient.SmsClient
|
SMSClient *aliyunsmsclient.SmsClient
|
||||||
|
|
||||||
|
QBiDaAPI *q_bida.Api // QBiDaApi
|
||||||
|
TelephoneAPI *recharge_phone_bill.API // 话费充值
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -151,14 +154,19 @@ func Init() {
|
|||||||
Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "localhost"), beego.AppConfig.DefaultInt("redisPort", 0), beego.AppConfig.DefaultString("redisPassword", ""))
|
Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "localhost"), beego.AppConfig.DefaultInt("redisPort", 0), beego.AppConfig.DefaultString("redisPassword", ""))
|
||||||
AliUpcAPI = aliupcapi.New(beego.AppConfig.String("aliUpcAppCode"))
|
AliUpcAPI = aliupcapi.New(beego.AppConfig.String("aliUpcAppCode"))
|
||||||
TxAPI = txcloudapi.New(beego.AppConfig.String("txCloudSecretID"), beego.AppConfig.String("txCloudSecretKey"))
|
TxAPI = txcloudapi.New(beego.AppConfig.String("txCloudSecretID"), beego.AppConfig.String("txCloudSecretKey"))
|
||||||
DingDingAPI = dingdingapi.NewWithAgentID(beego.AppConfig.DefaultInt64("dingdingAgentID", 0), beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingAppKey", ""), beego.AppConfig.DefaultString("dingdingSecret", ""))
|
DingDingAPI = dingdingapi.NewWithAgentID(beego.AppConfig.DefaultInt64("dingdingAgentID", 0), beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingAppKey", ""), beego.AppConfig.DefaultString("dingdingSecret", ""), "", "")
|
||||||
DingDingQRCodeAPI = dingdingapi.New(beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingQRCodeAppKey", ""), beego.AppConfig.DefaultString("dingdingQRCodeSecret", ""))
|
DingDingQRCodeAPI = dingdingapi.New(beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingQRCodeAppKey", ""), beego.AppConfig.DefaultString("dingdingQRCodeSecret", ""))
|
||||||
|
|
||||||
if alipayAppID := beego.AppConfig.DefaultString("alipayAppID", ""); alipayAppID != "" {
|
if alipayAppID := beego.AppConfig.DefaultString("alipayAppID", ""); alipayAppID != "" {
|
||||||
AliPayAPI = alipayapi.New(alipayAppID, []byte(beego.AppConfig.String("alipayPrivateKey")))
|
AliPayAPI = alipayapi.New(alipayAppID, []byte(beego.AppConfig.String("alipayPrivateKey")))
|
||||||
}
|
}
|
||||||
EjyAPI = ejyapi.New(beego.AppConfig.DefaultString("ejyPlatName", ""), beego.AppConfig.DefaultString("ejyBeforeKey", ""), beego.AppConfig.DefaultString("ejyAfterKey", ""))
|
EjyAPI = ejyapi.New(beego.AppConfig.DefaultString("ejyPlatName", ""), beego.AppConfig.DefaultString("ejyBeforeKey", ""), beego.AppConfig.DefaultString("ejyAfterKey", ""))
|
||||||
PushAPI = unipushapi.New(beego.AppConfig.DefaultString("pushAppID", ""), beego.AppConfig.DefaultString("pushAppKey", ""), beego.AppConfig.DefaultString("pushAppSecret", ""), beego.AppConfig.DefaultString("pushMasterSecret", ""))
|
//PushAPI = unipushapi.New(beego.AppConfig.DefaultString("pushAppID", ""), beego.AppConfig.DefaultString("pushAppKey", ""), beego.AppConfig.DefaultString("pushAppSecret", ""), beego.AppConfig.DefaultString("pushMasterSecret", ""))
|
||||||
MtMemberAPI = mtmemberapi.New()
|
MtMemberAPI = mtmemberapi.New()
|
||||||
SMSClient = aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/")
|
SMSClient = aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/")
|
||||||
|
|
||||||
|
// 初始化QBIDA
|
||||||
|
QBiDaAPI = q_bida.NewQBiDa(beego.AppConfig.DefaultString("QBiDaAccess", ""), beego.AppConfig.DefaultString("QBiDaPassword", ""))
|
||||||
|
// 话费充值
|
||||||
|
TelephoneAPI = recharge_phone_bill.New(beego.AppConfig.DefaultString("PasswordNo", ""), beego.AppConfig.DefaultString("AccountNo", ""), beego.AppConfig.DefaultString("PhoneScenery", ""))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,47 +4,79 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||||
beego "github.com/astaxie/beego/adapter"
|
beego "github.com/astaxie/beego/adapter"
|
||||||
"github.com/astaxie/beego/adapter/orm"
|
"github.com/astaxie/beego/client/orm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
// set default database
|
// set default database
|
||||||
orm.RegisterDataBase("default", "mysql", beego.AppConfig.String("dbConnectStr"), 30)
|
if beego.BConfig.RunMode == "rsm" {
|
||||||
// orm.RegisterDataBase("c4", "mysql", "root:WebServer@1@tcp(gold1.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true", 30)
|
orm.RegisterDataBase("default", "mysql", beego.AppConfig.String("dbConnectStr"))
|
||||||
|
//用户
|
||||||
|
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
||||||
|
orm.RegisterModel(&model.UserMember{})
|
||||||
|
orm.RegisterModel(&model.UserDeliveryAddress{})
|
||||||
|
orm.RegisterModel(&model.UserCityManager{})
|
||||||
|
orm.RegisterModel(&model.UserSearch{})
|
||||||
|
orm.RegisterModel(&model.UserUnionBind{}) //联盟相关绑定
|
||||||
|
orm.RegisterModel(&model.UserUnionBindImg{}) //多个活动图片
|
||||||
|
//账单
|
||||||
|
orm.RegisterModel(&model.UserBill{})
|
||||||
|
orm.RegisterModel(&model.BillIncome{})
|
||||||
|
orm.RegisterModel(&model.BillExpend{})
|
||||||
|
orm.RegisterModel(&model.MixPay{}) //混合支付
|
||||||
|
//支付订单
|
||||||
|
orm.RegisterModel(&model.Order{})
|
||||||
|
orm.RegisterModel(&model.DeliveryOrder{})
|
||||||
|
//联盟订单
|
||||||
|
orm.RegisterModel(&model.UnionOrder{})
|
||||||
|
orm.RegisterModel(&model.UnionOrderStatus{})
|
||||||
|
orm.RegisterModel(&model.UnionOrderSettle{}) //订单结算
|
||||||
|
//任务
|
||||||
|
orm.RegisterModel(&model.Job{}, &model.JobCategory{}, &model.JobStep{}, &model.JobImg{})
|
||||||
|
orm.RegisterModel(&model.JobOrder{})
|
||||||
|
orm.RegisterModel(&model.JobTimer{})
|
||||||
|
orm.RegisterModel(&model.JobSpan{})
|
||||||
|
//聊天
|
||||||
|
orm.RegisterModel(&model.ImMessageRecord{}, &model.MessageGroup{}, &model.MessageGroupMember{})
|
||||||
|
orm.RegisterModel(&model.MessageGroupRead{})
|
||||||
|
|
||||||
//用户
|
orm.RegisterModel(&model.Place{}, &model.StationInfo{})
|
||||||
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
orm.RegisterModel(&model.OperateEventDetail{})
|
||||||
orm.RegisterModel(&model.UserMember{})
|
orm.RegisterModel(&model.MtMember{})
|
||||||
orm.RegisterModel(&model.UserDeliveryAddress{})
|
orm.RegisterModel(&model.OperateEvent{})
|
||||||
orm.RegisterModel(&model.UserCityManager{})
|
orm.RegisterModel(&model.NewConfig{}, &legacymodel.Config{})
|
||||||
orm.RegisterModel(&model.UserSearch{})
|
orm.RegisterModel(&model.AddressDistinguish{})
|
||||||
orm.RegisterModel(&model.UserUnionBind{}) //联盟相关绑定
|
orm.RegisterModel(&model.VendorMatterCategory{}) //平台物流分类(手动添的)
|
||||||
orm.RegisterModel(&model.UserUnionBindImg{}) //多个活动图片
|
orm.RegisterModel(&model.OrderPayRefund{}) // 退款表
|
||||||
//账单
|
orm.RegisterModel(&model.UserVendorOrder{}) // 物流订单
|
||||||
orm.RegisterModel(&model.UserBill{}, &model.BillIncome{}, &model.BillExpend{})
|
orm.RegisterModel(&model.WithdrawalRecord{}) // 提现申请
|
||||||
//支付订单
|
} else {
|
||||||
orm.RegisterModel(&model.Order{})
|
orm.RegisterDataBase("default", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
orm.RegisterModel(&model.DeliveryOrder{})
|
// 打印机,迁移至api做
|
||||||
//联盟订单
|
orm.RegisterModel(&model.Apps{})
|
||||||
orm.RegisterModel(&model.UnionOrder{})
|
orm.RegisterModel(&model.Printer{}, &model.PrintMsg{}, &model.PrintSetting{}, &model.SystemTemp{})
|
||||||
orm.RegisterModel(&model.UnionOrderStatus{})
|
orm.RegisterModel(&model.NewConfig{})
|
||||||
orm.RegisterModel(&model.UnionOrderSettle{}) //订单结算
|
//orm.RegisterModel(&model.User{})
|
||||||
//任务
|
orm.RegisterModel(&model.Place{})
|
||||||
orm.RegisterModel(&model.Job{}, &model.JobCategory{}, &model.JobStep{}, &model.JobImg{})
|
orm.RegisterModel(&model.Menu{})
|
||||||
orm.RegisterModel(&model.JobOrder{})
|
orm.RegisterModel(&model.MenuDetail{})
|
||||||
orm.RegisterModel(&model.JobTimer{})
|
orm.RegisterModel(&model.SimFlowExpend{}, &model.SimFlowIncome{})
|
||||||
orm.RegisterModel(&model.JobSpan{})
|
orm.RegisterModel(&model.PayOrder{})
|
||||||
//聊天
|
orm.RegisterModel(&model.PrintBill{})
|
||||||
orm.RegisterModel(&model.ImMessageRecord{}, &model.MessageGroup{}, &model.MessageGroupMember{})
|
orm.RegisterModel(&model.OrderPay{})
|
||||||
orm.RegisterModel(&model.MessageGroupRead{})
|
orm.RegisterModel(&model.PrintBillRecord{})
|
||||||
|
orm.RegisterModel(&model.PrintBindStore{})
|
||||||
orm.RegisterModel(&model.Place{}, &model.StationInfo{})
|
orm.RegisterModel(&model.PrintActivation{})
|
||||||
orm.RegisterModel(&model.OperateEventDetail{})
|
orm.RegisterModel(&model.PrintNotice{})
|
||||||
orm.RegisterModel(&model.MtMember{})
|
orm.RegisterModel(&model.PrintEdition{})
|
||||||
orm.RegisterModel(&model.OperateEvent{})
|
}
|
||||||
orm.RegisterModel(&model.NewConfig{}, &legacymodel.Config{})
|
|
||||||
orm.RegisterModel(&model.AddressDistinguish{})
|
|
||||||
orm.RegisterModel(&model.VendorMatterCategory{}) //平台物流分类(手动添的)
|
|
||||||
// create table
|
// create table
|
||||||
orm.RunSyncdb("default", false, true)
|
orm.RunSyncdb("default", false, true)
|
||||||
|
|
||||||
|
//beego.NewNamespace("/print").Namespace(
|
||||||
|
// beego.NewNamespace("/v1").Get("/v2", func(context *context.Context) {
|
||||||
|
// context.Output.Body([]byte{})
|
||||||
|
// }),
|
||||||
|
//)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,14 +136,14 @@ func Init() {
|
|||||||
IsStoreSkuAct = !IsProductEnv()
|
IsStoreSkuAct = !IsProductEnv()
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsCallbackAlwaysReturnSuccess() bool {
|
|
||||||
return beego.BConfig.RunMode == "beta"
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsMainProductEnv() bool {
|
func IsMainProductEnv() bool {
|
||||||
return beego.BConfig.RunMode == "rsm"
|
return beego.BConfig.RunMode == "rsm"
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsProductEnv() bool {
|
func IsProductEnv() bool {
|
||||||
|
return beego.BConfig.RunMode == "rsm"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsPrintEnv() bool {
|
||||||
return beego.BConfig.RunMode == "print"
|
return beego.BConfig.RunMode == "print"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
package testinit1
|
package testinit1
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/beegodb"
|
|
||||||
"github.com/astaxie/beego"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
_, file, _, _ := runtime.Caller(0)
|
//_, file, _, _ := runtime.Caller(0)
|
||||||
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator)+".."+string(filepath.Separator))))
|
//apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator)+".."+string(filepath.Separator))))
|
||||||
beego.TestBeegoInit(apppath)
|
//beego.TestBeegoInit(apppath)
|
||||||
|
//
|
||||||
globals.SugarLogger.Infof("testinit RunMode=%s", beego.BConfig.RunMode)
|
//globals.SugarLogger.Infof("testinit RunMode=%s", beego.BConfig.RunMode)
|
||||||
beego.BConfig.RunMode = "dev" // InitBeegoBeforeTest会将runmode设置为test
|
//beego.BConfig.RunMode = "dev" // InitBeegoBeforeTest会将runmode设置为test
|
||||||
|
//
|
||||||
globals.Init()
|
//globals.Init()
|
||||||
beegodb.Init()
|
//beegodb.Init()
|
||||||
}
|
}
|
||||||
|
|||||||
111
main.go
111
main.go
@@ -3,25 +3,25 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||||
"net"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/controllers"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
|
|
||||||
|
|
||||||
beego "github.com/astaxie/beego/server/web"
|
beego "github.com/astaxie/beego/server/web"
|
||||||
|
|
||||||
// 导入缺省订单调度器
|
// 导入缺省订单调度器
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/beegodb"
|
"git.rosy.net.cn/jx-callback/globals/beegodb"
|
||||||
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay"
|
||||||
@@ -29,10 +29,10 @@ import (
|
|||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/jds"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/jds"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/mt"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/mt"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/taobao"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/taobao"
|
||||||
_ "git.rosy.net.cn/jx-callback/globals/api"
|
_ "git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
|
||||||
_ "git.rosy.net.cn/jx-callback/routers"
|
_ "git.rosy.net.cn/jx-callback/routers"
|
||||||
@@ -56,6 +56,8 @@ func Init() {
|
|||||||
}
|
}
|
||||||
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
||||||
misc.Init()
|
misc.Init()
|
||||||
|
controllers.Init()
|
||||||
|
dao.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回true表示非运行服务
|
// 返回true表示非运行服务
|
||||||
@@ -102,24 +104,8 @@ func checkCmdFlags() bool {
|
|||||||
func main() {
|
func main() {
|
||||||
if !checkCmdFlags() {
|
if !checkCmdFlags() {
|
||||||
Init()
|
Init()
|
||||||
// if err := tasks.RefreshWeixinToken(); err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("RefreshWeixinToken failed with error:%s", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if err := tasks.RefreshWeixin2Token(); err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("RefreshWeixin2Token failed with error:%s", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if err := tasks.RefreshWeixin3Token(); err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("RefreshWeixin3Token failed with error:%s", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if err := tasks.RefreshPushToken(); err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("RefreshPushToken failed with error:%s", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// 延时的原因是等回调准备好
|
// 延时的原因是等回调准备好
|
||||||
if globals.IsProductEnv() || beego.BConfig.RunMode == "beta" {
|
if globals.IsMainProductEnv() || beego.BConfig.RunMode == "beta" {
|
||||||
utils.AfterFuncWithRecover(2*time.Second, func() {
|
utils.AfterFuncWithRecover(2*time.Second, func() {
|
||||||
if err := tasks.RefreshDingDingToken(); err != nil {
|
if err := tasks.RefreshDingDingToken(); err != nil {
|
||||||
globals.SugarLogger.Errorf("RefreshDingDingToken failed with error:%s", err)
|
globals.SugarLogger.Errorf("RefreshDingDingToken failed with error:%s", err)
|
||||||
@@ -132,8 +118,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
cms.ResetJobTimers()
|
||||||
}
|
}
|
||||||
cms.ResetJobTimers()
|
|
||||||
if beego.BConfig.RunMode != "prod" {
|
if beego.BConfig.RunMode != "prod" {
|
||||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||||
@@ -145,71 +131,10 @@ func main() {
|
|||||||
http.ListenAndServe("0.0.0.0:6060", nil)
|
http.ListenAndServe("0.0.0.0:6060", nil)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if globals.IsProductEnv() {
|
|
||||||
l, err := net.Listen("tcp", ":8000")
|
if globals.IsPrintEnv() {
|
||||||
if err != nil {
|
go event.ListenTcp()
|
||||||
fmt.Println("listen error:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for {
|
|
||||||
c, err := l.Accept()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("accept error:", err)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
go handleConn(c)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleConn(c net.Conn) {
|
|
||||||
if c == nil {
|
|
||||||
fmt.Println("conn is nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer c.Close()
|
|
||||||
//reader := bufio.NewReader(c)
|
|
||||||
buffer := make([]byte, 1024)
|
|
||||||
for {
|
|
||||||
n, err := c.Read(buffer)
|
|
||||||
//ReadString阻塞,直到读到\n
|
|
||||||
//msg, err := reader.ReadString('\n')
|
|
||||||
if err != nil {
|
|
||||||
if err == io.EOF {
|
|
||||||
fmt.Println("connection close")
|
|
||||||
} else {
|
|
||||||
fmt.Println("ReadString err", err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("read data:", string(buffer[:n]))
|
|
||||||
b := []byte("ok")
|
|
||||||
c.Write(b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//func handleConn(c net.Conn) {
|
|
||||||
// if c == nil {
|
|
||||||
// fmt.Println("conn is nil")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// defer c.Close()
|
|
||||||
// //reader := bufio.NewReader(c)
|
|
||||||
// buffer := make([]byte, 1024)
|
|
||||||
// for {
|
|
||||||
// n, err := c.Read(buffer)
|
|
||||||
// if err != nil {
|
|
||||||
// if err == io.EOF {
|
|
||||||
// fmt.Println("connection close")
|
|
||||||
// } else {
|
|
||||||
// fmt.Println("ReadString err", err)
|
|
||||||
// }
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// fmt.Println("read data:", buffer[:n])
|
|
||||||
// b := []byte("ok")
|
|
||||||
// c.Write(b)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -808,6 +808,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "PayByBalance",
|
||||||
|
Router: "/PayByBalance",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "CancelTask",
|
Method: "CancelTask",
|
||||||
@@ -1015,4 +1024,182 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
// 快递运单,查询物流运费
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "QueryExpressPrice",
|
||||||
|
Router: "/QueryExpressPrice",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 创建物流订单
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "CreateWayOrder",
|
||||||
|
Router: "/CreateWayOrder",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 取消物流运单
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "CancelWayVendorOrder",
|
||||||
|
Router: "/CancelWayVendorOrder",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 获取用户订单列表
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "QueryUserOrderList",
|
||||||
|
Router: "/QueryUserOrderList",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 获取用户订单详情
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetOrderDetail",
|
||||||
|
Router: "/GetOrderDetail",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 管理系统获取订单详情
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetOrderList",
|
||||||
|
Router: "/GetOrderList",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 删除订单
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "DeleteOrder",
|
||||||
|
Router: "/DeleteOrder",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 再来一单
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "TryAgainOrderByOldOrder",
|
||||||
|
Router: "/TryAgainOrderByOldOrder",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 修改用户账户余额
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserBalanceController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserBalanceController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "UpdateUserBalance",
|
||||||
|
Router: "/UpdateUserBalance",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 提现申请:用户发起提现申请
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "AddWithdrawalRecord",
|
||||||
|
Router: "/AddWithdrawalRecord",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 提现申请:取消或者删除提现生情
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "DeleteWithdrawalRecord",
|
||||||
|
Router: "/DeleteWithdrawalRecord",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 提现申请:用户查询申请列表
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetWithdrawalRecord",
|
||||||
|
Router: "/GetWithdrawalRecord",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 提现申请:管理系统查询列表
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetWithdrawalList",
|
||||||
|
Router: "/GetWithdrawalList",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
// 提现申请:审核提现申请
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:WithdrawalRecordController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "ExamineWithdrawalOrder",
|
||||||
|
Router: "/ExamineWithdrawalOrder",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 用户查询充值列表
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetUserRecharge",
|
||||||
|
Router: "/GetUserRecharge",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 用户查询平台订单详情
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetRechargeOrderDetail",
|
||||||
|
Router: "/GetRechargeOrderDetail",
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 管理系统查询平台订单
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "SystemQueryRechargeList",
|
||||||
|
Router: "/SystemQueryRechargeList",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 查询当前账号余额
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:RechargeManagerController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "QueryAccountBill",
|
||||||
|
Router: "/QueryAccountBill",
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
// 打印机api
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ApiController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ApiController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "CallOpenAPI",
|
||||||
|
Router: "/CallOpenAPI",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ package routers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-callback/controllers"
|
"git.rosy.net.cn/jx-callback/controllers"
|
||||||
|
|
||||||
"github.com/astaxie/beego/server/web"
|
"github.com/astaxie/beego/server/web"
|
||||||
beecontext "github.com/astaxie/beego/server/web/context"
|
beecontext "github.com/astaxie/beego/server/web/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// 冲天猴
|
||||||
ns := web.NewNamespace("/v2",
|
ns := web.NewNamespace("/v2",
|
||||||
web.NSNamespace("/task",
|
web.NSNamespace("/task",
|
||||||
web.NSInclude(
|
web.NSInclude(
|
||||||
@@ -61,12 +61,48 @@ func init() {
|
|||||||
&controllers.UnionController{},
|
&controllers.UnionController{},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// QBiDa
|
||||||
|
web.NSNamespace("/express",
|
||||||
|
web.NSInclude(
|
||||||
|
&controllers.QBiDaExpressController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 用户账户余额
|
||||||
|
web.NSNamespace("/balance",
|
||||||
|
web.NSInclude(
|
||||||
|
&controllers.UserBalanceController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 提现申请
|
||||||
|
web.NSNamespace("/withdrawal",
|
||||||
|
web.NSInclude(
|
||||||
|
&controllers.WithdrawalRecordController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// 话费充值
|
||||||
|
web.NSNamespace("/recharge",
|
||||||
|
web.NSInclude(
|
||||||
|
&controllers.RechargeManagerController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
/*****************打印机openAPI**********************/
|
||||||
|
web.NSNamespace("/openapi",
|
||||||
|
web.NSInclude(
|
||||||
|
&controllers.ApiController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
web.AddNamespace(ns)
|
web.AddNamespace(ns)
|
||||||
|
// 冲天猴接口
|
||||||
web.AutoRouter(&controllers.WXPayController{})
|
web.AutoRouter(&controllers.WXPayController{})
|
||||||
web.AutoRouter(&controllers.TongLianController{})
|
web.AutoRouter(&controllers.TongLianController{})
|
||||||
|
web.AutoRouter(&controllers.RechargeController{}) // 充值话费回调
|
||||||
web.AutoRouter(&controllers.MTWMController{})
|
web.AutoRouter(&controllers.MTWMController{})
|
||||||
web.AutoRouter(&controllers.PrintController{})
|
web.AutoRouter(&controllers.PrintController{})
|
||||||
|
web.AutoRouter(&controllers.QBiDaExpressController{})
|
||||||
|
|
||||||
// 如下都是用于检测存活的空接口
|
// 如下都是用于检测存活的空接口
|
||||||
web.Any("/", func(ctx *beecontext.Context) {
|
web.Any("/", func(ctx *beecontext.Context) {
|
||||||
|
|||||||
16896
swagger/param_parser.go.txt
Normal file
16896
swagger/param_parser.go.txt
Normal file
File diff suppressed because it is too large
Load Diff
5818
swagger/swagger.json
Normal file
5818
swagger/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
3945
swagger/swagger.yml
Normal file
3945
swagger/swagger.yml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,6 @@ import (
|
|||||||
_ "git.rosy.net.cn/jx-callback/routers"
|
_ "git.rosy.net.cn/jx-callback/routers"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
. "github.com/smartystreets/goconvey/convey"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user