@@ -38,7 +38,7 @@ public class TestAccounting {
38
38
// static String HOST = "btsoomrtb";
39
39
// static String HOST = "54.175.237.122";
40
40
// static String HOST = "rtb4free.com";
41
- static String winnah = "__COST__/__LAT__/__LON__/__ADID__/__CRID__/__BIDID__/http://__HOST__:8080/contact.html?99201&adid=__ADID__&crid=__CRID__/http://__HOST__:8080/images/320x50.jpg?adid=__ADID__&__BIDID__ " ;
41
+ static String winnah = "__COST__/__LAT__/__LON__/__ADID__/__CRID__/__BIDID__" ;
42
42
43
43
static String pixel = "/pixel/__EXCHANGE__/__ADID__/__CRID__/__BIDID__/__COST__/__LAT__/__LON__" ;
44
44
@@ -157,8 +157,9 @@ public static void main(String[] args) throws Exception {
157
157
BigDecimal wc = new BigDecimal (str );
158
158
winCost = winCost .add (wc );
159
159
rets .put ("uuid" , uuid );
160
- String theWin = makeWin (map , theBid , rets , wc .doubleValue ());
161
- String rc = post .sendGet (thisWinUrl + theWin , 5000 , 5000 );
160
+ String xwin = (String )theBid .get ("nurl" );
161
+ String theWin = makeWin2 (map ,xwin ,rets ,wc .doubleValue ());
162
+ String rc = post .sendGet (theWin , 5000 , 5000 );
162
163
if (rc == null || rc .length () == 0 )
163
164
System .err .println ("Bad Win return" );
164
165
}
@@ -200,6 +201,58 @@ public static GeoStuff randomGeo() {
200
201
201
202
}
202
203
204
+ public static String makeWin2 (Map bid , String xwin , Map r , double dcost ) {
205
+ String [] parts = xwin .split ("http" );
206
+ String pre = xwin .substring (0 ,xwin .indexOf (":" ));
207
+ String lat = null ;
208
+ String lon = null ;
209
+ String uuid ;
210
+ String forward = "http:" + parts [1 ];
211
+ parts = parts [1 ].split ("/" );
212
+
213
+ parts [8 ] = "" + dcost ;
214
+
215
+ if (COUNT_MODE ) {
216
+ lat = "" + (double ) r .get ("lat" );
217
+ lon = "" + (double ) r .get ("lon" );
218
+ uuid = (String ) r .get ("uuid" );
219
+ } else {
220
+ Map device = (Map ) bid .get ("device" );
221
+ if (device != null ) {
222
+ Map geo = (Map ) device .get ("geo" );
223
+ if (geo != null ) {
224
+ Double x = (Double ) geo .get ("lat" );
225
+ if (x != null ) {
226
+ lat = "" + x ;
227
+ x = (Double ) geo .get ("lon" );
228
+ lon = "" + x ;
229
+ }
230
+ }
231
+ }
232
+ uuid = (String ) bid .get ("id" );
233
+ }
234
+
235
+ /**
236
+ * Random cost
237
+ */
238
+ Random rand = new Random ();
239
+ int Low = 760 ;
240
+ int High = 1000 ;
241
+ double Result = .001 * (rand .nextInt (High - Low ) + Low );
242
+ // cost = "" + Result * COST;
243
+
244
+ parts [9 ] = lat ;
245
+ parts [10 ] = lon ;
246
+ parts [13 ] = uuid ;
247
+
248
+
249
+ String str = pre + ":/" ;
250
+ for (int i =2 ; i <parts .length ;i ++) {
251
+ str = str + "/" + parts [i ];
252
+ }
253
+ return str ;
254
+
255
+ }
203
256
public static String makeWin (Map bid , Map theBid , Map r , double dcost ) {
204
257
String str = winnah ;
205
258
String lat = "NA" ;
0 commit comments