Commit 7d49c581 by jianshuqin

新增功能:新开了3个站点shopify的广告费

parent 9e5181d5
...@@ -13,11 +13,11 @@ namespace Bailun.DC.SyncShopifyFee ...@@ -13,11 +13,11 @@ namespace Bailun.DC.SyncShopifyFee
public class Services : BackgroundService public class Services : BackgroundService
{ {
IList<string> listUrl = new string[] { IDictionary<string, string> dicWebsiteUrl = new Dictionary<string, string> {
"http://scrm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog", //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100 {"scrm", "http://scrm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog" }, //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100
"http://us.btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog", //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100 {"us", "http://us.btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog"}, //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100
"http://us2.btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog", //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100 {"us2", "http://us2.btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog"}, //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100
"http://au.btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog" //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100 {"au", "http://au.btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeLog"} //?btime=2021-10-01&etime=2021-10-03&page=1&rows=100
}; };
private Timer _timer; private Timer _timer;
...@@ -51,7 +51,7 @@ namespace Bailun.DC.SyncShopifyFee ...@@ -51,7 +51,7 @@ namespace Bailun.DC.SyncShopifyFee
public void Init(DateTime? btime = null, DateTime? etime = null) public void Init(DateTime? btime = null, DateTime? etime = null)
{ {
foreach (string url in listUrl) foreach (KeyValuePair<string, string> websiteUrl in dicWebsiteUrl)
{ {
var page = 1; var page = 1;
var pagesize = 1000; var pagesize = 1000;
...@@ -70,7 +70,7 @@ namespace Bailun.DC.SyncShopifyFee ...@@ -70,7 +70,7 @@ namespace Bailun.DC.SyncShopifyFee
{ {
try try
{ {
var result = Common.HttpHelper.NetHelper.Request($"{url}?btime={btime.Value.ToString("yyyy-MM-dd HH:00:00")}&etime={etime.Value.ToString("yyyy-MM-dd")}&page={page}&rows={pagesize}"); var result = Common.HttpHelper.NetHelper.Request($"{websiteUrl.Value}?btime={btime.Value.ToString("yyyy-MM-dd HH:00:00")}&etime={etime.Value.ToString("yyyy-MM-dd")}&page={page}&rows={pagesize}");
if (!string.IsNullOrEmpty(result)) if (!string.IsNullOrEmpty(result))
{ {
var json = JsonConvert.DeserializeObject<response_result>(result); var json = JsonConvert.DeserializeObject<response_result>(result);
...@@ -78,7 +78,7 @@ namespace Bailun.DC.SyncShopifyFee ...@@ -78,7 +78,7 @@ namespace Bailun.DC.SyncShopifyFee
if (json.success && count > 0) if (json.success && count > 0)
{ {
//保存数据 //保存数据
Save(json.data); Save(websiteUrl.Key, json.data);
} }
page++; page++;
} }
...@@ -92,7 +92,7 @@ namespace Bailun.DC.SyncShopifyFee ...@@ -92,7 +92,7 @@ namespace Bailun.DC.SyncShopifyFee
} }
} }
public void Save(IList<response_shopify_fee> list) public void Save(string website, IList<response_shopify_fee> list)
{ {
using (var db = new MySqlConnection(Common.GlobalConfig.ConnectionString_Data)) using (var db = new MySqlConnection(Common.GlobalConfig.ConnectionString_Data))
{ {
...@@ -105,7 +105,8 @@ namespace Bailun.DC.SyncShopifyFee ...@@ -105,7 +105,8 @@ namespace Bailun.DC.SyncShopifyFee
{ {
var m = JsonConvert.DeserializeObject<dc_base_finance_shopify_fee>(JsonConvert.SerializeObject(item)); var m = JsonConvert.DeserializeObject<dc_base_finance_shopify_fee>(JsonConvert.SerializeObject(item));
m.gmt_modified = DateTime.Now; m.gmt_modified = DateTime.Now;
int count = db.Execute("update dc_base_finance_shopify_fee set ad_id = @ad_id, ts = @ts, bdate = @bdate, edate = @edate, fee = @fee, account_currency = @account_currency, cny_exchange_rate = @cny_exchange_rate,gmt_modified = @gmt_modified where data_id=@data_id", m); m.website = website;
int count = db.Execute("update dc_base_finance_shopify_fee set website = @website, ad_id = @ad_id, ts = @ts, bdate = @bdate, edate = @edate, fee = @fee, account_currency = @account_currency, cny_exchange_rate = @cny_exchange_rate,gmt_modified = @gmt_modified where data_id=@data_id and website=@website", m);
if (count == 0) if (count == 0)
{ {
m.gmt_create = DateTime.Now; m.gmt_create = DateTime.Now;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment