Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
2e0cfa3b
Commit
2e0cfa3b
authored
Mar 14, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
f8fe653c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
211 additions
and
50 deletions
+211
-50
bpo-admin/app/base/api/impl/channelApi.js
+106
-2
bpo-admin/app/base/service/impl/channelSve.js
+4
-1
bpo-admin/app/base/service/impl/esettleSve.js
+19
-0
bpo-admin/app/base/service/impl/esettleofflineSve.js
+62
-46
bpo-admin/app/base/utils/aliyunClient.js
+4
-1
bpo-admin/app/config/settings.js
+16
-0
No files found.
bpo-admin/app/base/api/impl/channelApi.js
View file @
2e0cfa3b
var
system
=
require
(
"../../system"
)
var
system
=
require
(
"../../system"
);
var
settings
=
require
(
"../../../config/settings"
)
const
md5
=
require
(
"MD5"
);
const
logCtl
=
system
.
getObject
(
"web.oplogCtl"
);
const
moment
=
require
(
"moment"
);
...
...
@@ -107,7 +109,6 @@ class ChannelApi {
var
data
=
await
this
.
separateGet
(
queryobj
);
}
async
separateGet
(
queryobj
)
{
let
encry
=
system
.
decryption
(
queryobj
.
param
);
encry
=
JSON
.
parse
(
encry
);
...
...
@@ -173,6 +174,109 @@ class ChannelApi {
}
// -------------------------------------
async
pushChannels
(
queryobj
,
qobj
,
req
)
{
let
begin
;
let
end
;
if
(
queryobj
.
day
)
{
begin
=
queryobj
.
day
+
' 00:00:00'
;
/* 自定义时间 */
end
=
queryobj
.
day
+
' 23:59:59'
;
/* 自定义时间 */
}
else
{
begin
=
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-MM-DD 00:00:00'
);
/*前一天的时间*/
end
=
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-MM-DD 23:59:59'
);
/*前一天的时间*/
}
var
merchantIds
=
await
this
.
channelSve
.
getPushMerchantIds
()
||
[];
if
(
merchantIds
.
length
==
0
)
{
return
system
.
getErrResult2
(
"暂无绑定渠道"
);
}
for
(
let
merchantId
of
merchantIds
)
{
console
.
log
(
merchantId
,
"----------------------------"
);
// 查渠道商户id
let
merchant
=
(
await
this
.
channelSve
.
merchantInfo
({
id
:
merchantId
})
||
{}).
data
;
if
(
merchant
.
origin_id
==
10000
)
{
await
this
.
pushOnlineOrder
(
merchant
,
begin
,
end
);
}
else
{
await
this
.
pushOfflineOrder
(
merchant
,
begin
,
end
);
// let order = await this.esettleofflineSve.findById(merchant.data_id);
}
}
}
async
pushOnlineOrder
(
merchant
,
begin
,
end
)
{
let
orders
=
await
this
.
esettleSve
.
findPushInfos
(
merchant
.
origin_merchant_id
,
begin
,
end
)
||
[];
if
(
orders
.
length
==
0
)
{
return
;
}
for
(
let
order
of
orders
)
{
// 获取推送数据
let
pushData
=
this
.
getPushData
(
merchant
,
order
);
// 创建log
let
log
=
await
this
.
pushfqlogSve
.
create
(
pushData
.
log
);
// 推送数据
var
rc
=
system
.
getObject
(
"util.aliyunClient"
);
let
rtn
=
await
rc
.
post
(
this
.
FQURL
,
pushData
.
data
);
// 返回结果都保存到toPush中吧
log
.
topush
=
JSON
.
stringify
(
rtn
);
await
log
.
save
();
}
}
async
pushOfflineOrder
(
merchant
,
begin
,
end
)
{
let
orders
=
await
this
.
esettleofflineSve
.
findPushInfos
(
merchant
.
origin_merchant_id
,
begin
,
end
)
||
[];
if
(
orders
.
length
==
0
)
{
return
;
}
for
(
let
order
of
orders
)
{
// 获取推送数据
let
pushData
=
this
.
getPushData
(
merchant
,
order
);
// 创建log
let
log
=
await
this
.
pushfqlogSve
.
create
(
pushData
.
log
);
// 推送数据
var
rc
=
system
.
getObject
(
"util.aliyunClient"
);
let
rtn
=
await
rc
.
post
(
this
.
FQURL
,
pushData
.
data
);
// 返回结果都保存到toPush中吧
log
.
topush
=
JSON
.
stringify
({
rtn
});
await
log
.
save
();
}
}
getPushData
(
merchant
,
order
)
{
let
data
=
{
"idempotentId"
:
this
.
trim
(
order
.
id
),
// 业务编号(订单id)
"idempotentSource"
:
"bpo_xbg"
,
// 来源编号,写死:bpo_xbg
"idempotentSourceName"
:
"BPO"
,
// 来源编号,写死:BPO薪必果
"thirdPartyChannelId"
:
this
.
trim
(
merchant
.
channel_id
),
// 渠道id
"thirdPartyCustomerId"
:
this
.
trim
(
merchant
.
id
).
toString
(),
// 第三方客户id
// "productId": "5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境)
"productId"
:
settings
.
FQYF
().
productId
,
// 云服产品id (生产环境)
// "allotRatio":"50",// 分润比例(百分比的数字部分(如:50代表50%))
"orderPrice"
:
order
.
deduct_amt
,
// 订单金额
"productQuantity"
:
"1"
,
// 产品数量
"companyName"
:
merchant
.
merchant_name
,
// 公司名称
"phone"
:
merchant
.
contact_mobile
};
var
log
=
{
"data_id"
:
this
.
trim
(
order
.
id
),
// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id"
:
merchant
.
channel_id
,
//渠道id
"channel_merchant_id"
:
merchant
.
id
,
//渠道商户id
"origin_merchant_id"
:
merchant
.
origin_merchant_id
,
//来源商户id
};
data
.
param
=
encodeURIComponent
(
system
.
encryption
(
JSON
.
stringify
(
log
)));
return
{
data
:
data
,
param
:
log
,
}
}
async
orderInfo
(
queryobj
,
qobj
,
req
)
{
let
param
=
system
.
decryption
(
queryobj
.
data
);
// {"data_id":17,"channel_id":10002,"channel_merchant_id":"0","origin_merchant_id":"10048","pushplatform_channel_id":10000}
...
...
bpo-admin/app/base/service/impl/channelSve.js
View file @
2e0cfa3b
...
...
@@ -46,7 +46,6 @@ class ChannelService extends microService {
return
await
this
.
callms
(
"channel"
,
"pushbindingchannel"
,
params
);
}
// 商户api
async
merchantInfo
(
params
)
{
return
await
this
.
callms
(
"channel"
,
"merchantInfo"
,
params
);
...
...
@@ -57,5 +56,9 @@ class ChannelService extends microService {
async
merchantPage
(
params
)
{
return
await
this
.
callms
(
"channel"
,
"merchantPage"
,
params
);
}
async
getPushMerchantIds
(
params
){
return
await
this
.
callms
(
"channel"
,
"getPushMerchantIds"
,
params
);
}
}
module
.
exports
=
ChannelService
;
bpo-admin/app/base/service/impl/esettleSve.js
View file @
2e0cfa3b
...
...
@@ -902,5 +902,24 @@ class EsettleService extends ServiceBase {
return
{
count
:
total
,
rows
:
list
};
}
async
findPushInfos
(
busiId
,
begin
,
end
)
{
if
(
!
busiId
)
{
return
[];
}
let
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
"id, deduct_amt "
);
sql
.
push
(
"FROM `tbl_order` "
);
sql
.
push
(
"WHERE busi_id = :busiId"
);
sql
.
push
(
"AND pay_complete_time >= :begin"
);
sql
.
push
(
"AND pay_complete_time <= :end"
);
var
list
=
await
this
.
settledb
.
query
(
sql
.
join
(
" "
),
{
replacements
:
{
busiId
:
busiId
,
begin
:
begin
,
end
:
end
}
});
if
(
list
&&
list
.
length
>
0
)
{
list
=
list
[
0
,
0
]
||
[];
}
return
list
;
}
}
module
.
exports
=
EsettleService
;
bpo-admin/app/base/service/impl/esettleofflineSve.js
View file @
2e0cfa3b
This diff is collapsed.
Click to expand it.
bpo-admin/app/base/utils/aliyunClient.js
View file @
2e0cfa3b
const
settings
=
require
(
"../../config/settings"
);
const
Client
=
require
(
'aliyun-api-gateway'
).
Client
;
var
RPCClient
=
require
(
'@alicloud/pop-core'
).
RPCClient
;
// const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');//开发
const
client
=
new
Client
(
'203763771'
,
'e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu'
);
//线上
// const client = new Client('203763771', 'e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu');//线上
const
client
=
new
Client
(
settings
.
FQYF
().
k
,
settings
.
FQYF
().
v
);
//线上
class
aliyunClient
{
constructor
()
{
// this.aliReqUrl = "https://aliapi.gongsibao.com/tm/springboard";
...
...
bpo-admin/app/config/settings.js
View file @
2e0cfa3b
...
...
@@ -29,6 +29,21 @@ var settings = {
return
"http://43.247.184.94:7200/"
;
}
},
FQYF
:
function
()
{
if
(
settings
.
env
==
"dev"
)
{
return
{
k
:
"203756805"
,
v
:
"crkyej0xlmqa6bmvqijun6ltxparllyn"
,
productId
:
"5e6b02cc3290c3000a3a63dc"
,
// 云服产品id
};
}
else
{
return
{
k
:
"203763771"
,
v
:
"e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu"
,
productId
:
"5e6c89d54c52bf000a750bc5"
,
// 云服产品id (生产环境)
};
}
},
apiconfig
:
{
AES
:
{
key
:
"qUPsMflPfgpPP1Ua"
,
//密钥
...
...
@@ -59,6 +74,7 @@ var settings = {
return
"https://o.tsign.cn/opentreaty-service"
;
}
},
//e签宝银行验证接口Url
eSignBaoBankVerifyUrl
:
function
()
{
if
(
settings
.
env
==
"dev"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment