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
3edcab1d
Commit
3edcab1d
authored
Mar 13, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
f050de22
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
210 additions
and
6 deletions
+210
-6
bpo-admin/app/base/api/impl/channelApi.js
+107
-4
bpo-admin/app/base/service/impl/channelSve.js
+1
-0
bpo-admin/app/base/service/impl/esettleSve.js
+24
-2
bpo-admin/app/base/utils/aliyunClient.js
+77
-0
bpo-admin/package.json
+1
-0
No files found.
bpo-admin/app/base/api/impl/channelApi.js
View file @
3edcab1d
...
@@ -5,6 +5,10 @@ const moment = require("moment");
...
@@ -5,6 +5,10 @@ const moment = require("moment");
class
ChannelApi
{
class
ChannelApi
{
constructor
()
{
constructor
()
{
this
.
channelSve
=
system
.
getObject
(
"service.channelSve"
);
this
.
channelSve
=
system
.
getObject
(
"service.channelSve"
);
this
.
esettleSve
=
system
.
getObject
(
"service.esettleSve"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
esettleofflineitemSve
=
system
.
getObject
(
"service.esettleofflineitemSve"
);
this
.
FQURL
=
"http://yunfuapi-dev.gongsibao.com/crm/order/submit"
}
}
//渠道绑定
//渠道绑定
...
@@ -24,13 +28,112 @@ class ChannelApi {
...
@@ -24,13 +28,112 @@ class ChannelApi {
//绑定渠道推送
//绑定渠道推送
async
pushbindingchannel
(
queryobj
,
qobj
,
req
){
async
pushbindingchannel
(
queryobj
,
qobj
,
req
){
queryobj
.
begin
=
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-MM-DD 00:00:00'
);
/*前一天的时间*/
queryobj
.
begin
=
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-MM-DD 00:00:00'
);
/*前一天的时间*/
queryobj
.
end
=
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-MM-DD 23:59:59'
);
/*前一天的时间*/
queryobj
.
end
=
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-MM-DD 23:59:59'
);
/*前一天的时间*/
console
.
log
(
queryobj
);
var
result
=
await
this
.
channelSve
.
pushbindingchannel
(
queryobj
);
var
result
=
await
this
.
channelSve
.
pushbindingchannel
(
queryobj
);
return
result
;
var
data
=
result
.
data
;
if
(
data
.
length
>
0
){
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
){
if
(
data
[
i
].
channel_id
==
'10000'
&&
data
[
i
].
origin_merchant_id
!=
''
){
var
busiData
=
await
this
.
esettleSve
.
findBybusiId
(
data
[
i
].
origin_merchant_id
);
if
(
busiData
.
length
>
0
){
for
(
let
j
=
0
;
j
<
busiData
.
length
;
j
++
){
var
pushData
=
this
.
getBusiData
(
busiData
[
j
],
data
[
i
]);
var
rc
=
system
.
getObject
(
"util.aliyunClient"
);
var
rtn
=
null
;
rtn
=
await
rc
.
post
(
this
.
FQURL
,
pushData
);
console
.
log
(
pushData
)
console
.
log
(
rtn
)
}
}
}
else
{
if
(
data
[
i
].
origin_merchant_id
!=
''
){
var
esettleoffline
=
await
this
.
esettleofflineSve
.
findOne
({
"ecompany_id"
:
data
[
i
].
origin_merchant_id
});
if
(
esettleoffline
!=
null
){
var
pushData
=
this
.
getBusiDatas
(
esettleoffline
.
dataValues
,
data
[
i
]);
var
rc
=
system
.
getObject
(
"util.aliyunClient"
);
var
rtn
=
null
;
rtn
=
await
rc
.
post
(
this
.
FQURL
,
pushData
);
console
.
log
(
pushData
)
console
.
log
(
rtn
)
}
}
}
}
}
}
async
paydayCount
(
queryobj
,
qobj
,
req
){
var
data
=
await
this
.
separateGet
(
queryobj
);
console
.
log
(
data
.
dataValues
)
}
async
paydayDetails
(
queryobj
,
qobj
,
req
){
var
data
=
await
this
.
separateGet
(
queryobj
);
}
async
separateGet
(
queryobj
){
let
encry
=
system
.
decryption
(
queryobj
.
param
);
encry
=
JSON
.
parse
(
encry
);
if
(
encry
.
channel_id
==
10000
){
var
busiData
=
await
this
.
esettleSve
.
findByIdList
(
encry
.
data_id
);
return
busiData
;
}
var
esettleoffline
=
await
this
.
esettleofflineitemSve
.
find
({
"esettleoffline_id"
:
encry
.
data_id
});
return
esettleoffline
;
}
getBusiData
(
da
,
chnanel
){
var
resultData
=
{
"idempotentId"
:
da
.
out_trade_no
,
// 业务编号(订单id)
"idempotentSource"
:
"bpo_xbg"
,
// 来源编号,写死:bpo_xbg
"idempotentSourceName"
:
"BPO"
,
// 来源编号,写死:BPO薪必果
"thirdPartyChannelId"
:
"10000"
,
// 渠道id
"thirdPartyCustomerId"
:
da
.
busi_id
,
// 第三方客户id
"productId"
:
"5e6b02cc3290c3000a3a63dc"
,
// 云服产品id (测试环境)
"allotRatio"
:
"50"
,
// 分润比例(百分比的数字部分(如:50代表50%))
"orderPrice"
:
da
.
deduct_amt
,
// 订单金额
"productQuantity"
:
"1"
,
// 产品数量
"companyName"
:
chnanel
.
merchant_name
,
// 公司名称
"phone"
:
"13722223333"
};
var
str
=
{
"data_id"
:
da
.
id
,
// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id"
:
chnanel
.
channel_id
,
//渠道id
"channel_merchant_id"
:
da
.
busi_id
,
//渠道商户id
"origin_merchant_id"
:
chnanel
.
origin_merchant_id
,
//来源商户id
"pushplatform_channel_id"
:
chnanel
.
platform_id
,
//对方渠道id
};
let
encry
=
System
.
encryption
(
JSON
.
stringify
(
str
));
resultData
.
param
=
system
.
encryption
(
encry
);
return
resultData
;
}
getBusiDatas
(
da
,
chnanel
){
var
resultData
=
{
"idempotentId"
:
da
.
id
,
// 业务编号(订单id)
"idempotentSource"
:
"bpo_xbg"
,
// 来源编号,写死:bpo_xbg
"idempotentSourceName"
:
"BPO"
,
// 来源编号,写死:BPO薪必果
"thirdPartyChannelId"
:
"10000"
,
// 渠道id
"thirdPartyCustomerId"
:
da
.
busi_id
,
// 第三方客户id
"productId"
:
"5e6b02cc3290c3000a3a63dc"
,
// 云服产品id (测试环境)
"allotRatio"
:
"50"
,
// 分润比例(百分比的数字部分(如:50代表50%))
"orderPrice"
:
da
.
amt
,
// 订单金额
"productQuantity"
:
"1"
,
// 产品数量
"companyName"
:
da
.
ecompanyName
,
// 公司名称
"phone"
:
"13722223333"
};
var
str
=
{
"data_id"
:
da
.
id
,
// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id"
:
chnanel
.
channel_id
,
//渠道id
"channel_merchant_id"
:
da
.
busi_id
,
//渠道商户id
"origin_merchant_id"
:
chnanel
.
origin_merchant_id
,
//来源商户id
"pushplatform_channel_id"
:
chnanel
.
platform_id
,
//对方渠道id
};
resultData
.
param
=
system
.
encryption
(
JSON
.
stringify
(
str
));
return
resultData
;
}
}
...
...
bpo-admin/app/base/service/impl/channelSve.js
View file @
3edcab1d
...
@@ -46,6 +46,7 @@ class ChannelService extends microService {
...
@@ -46,6 +46,7 @@ class ChannelService extends microService {
return
await
this
.
callms
(
"channel"
,
"pushbindingchannel"
,
params
);
return
await
this
.
callms
(
"channel"
,
"pushbindingchannel"
,
params
);
}
}
// 商户api
// 商户api
async
merchantInfo
(
params
)
{
async
merchantInfo
(
params
)
{
return
await
this
.
callms
(
"channel"
,
"merchantInfo"
,
params
);
return
await
this
.
callms
(
"channel"
,
"merchantInfo"
,
params
);
...
...
bpo-admin/app/base/service/impl/esettleSve.js
View file @
3edcab1d
...
@@ -825,5 +825,28 @@ class EsettleService extends ServiceBase {
...
@@ -825,5 +825,28 @@ class EsettleService extends ServiceBase {
}
}
return
list
;
return
list
;
}
}
async
findBybusiId
(
busiId
){
if
(
!
busiId
){
return
[];
}
var
sql
=
"SELECT * FROM `tbl_order` WHERE busi_id = :busiId"
;
var
list
=
await
this
.
settledb
.
query
(
sql
,
{
replacements
:
{
busiId
:
busiId
}
});
if
(
list
&&
list
.
length
>
0
)
{
list
=
list
[
0
,
0
]
||
[];
}
return
list
;
}
async
findByIdList
(
tblOrderId
){
if
(
!
busiId
){
return
[];
}
var
sql
=
"SELECT * FROM `tbl_order_item` WHERE order_id = :tblOrderId"
;
var
list
=
await
this
.
settledb
.
query
(
sql
,
{
replacements
:
{
tblOrderId
:
tblOrderId
}});
if
(
list
&&
list
.
length
>
0
)
{
list
=
list
[
0
,
0
]
||
[];
}
return
list
;
}
}
}
module
.
exports
=
EsettleService
;
module
.
exports
=
EsettleService
;
\ No newline at end of file
bpo-admin/app/base/utils/aliyunClient.js
0 → 100644
View file @
3edcab1d
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');//线上
class
aliyunClient
{
constructor
()
{
// this.aliReqUrl = "https://aliapi.gongsibao.com/tm/springboard";
this
.
aliclient
=
new
RPCClient
({
accessKeyId
:
'LTAI4FmyipY1wuLHjLhMWiPa'
,
accessKeySecret
:
'hp4FF18IDCSym1prqzxrAjnnhNH3ju'
,
endpoint
:
'https://trademark.aliyuncs.com'
,
apiVersion
:
'2018-07-24'
});
}
async
post
(
aliReqUrl
,
actionBody
)
{
// var reqParam = {};
// reqParam["ActionProcess"] = "AliTm";
// reqParam["ActionType"] = actionType;
// reqParam["ActionBody"] = actionBody;
// if (!actionBody.reqOnlyCode) {
// actionBody["reqOnlyCode"] = await this.getCreateOrderNum();
// }
var
param
=
{
data
:
actionBody
,
timeout
:
20000
,
headers
:
{
accept
:
'application/json'
}
};
console
.
log
(
JSON
.
stringify
(
param
),
"______________峰擎---阿里云参数_______"
);
var
result
=
await
client
.
post
(
aliReqUrl
,
param
);
console
.
log
(
JSON
.
stringify
(
result
),
"______________峰擎---阿里云返回结果_______"
);
return
result
;
}
//阿里接口
async
reqbyget
(
obj
,
cbk
)
{
var
self
=
this
;
var
action
=
obj
.
action
;
var
reqbody
=
obj
.
reqbody
;
return
self
.
aliclient
.
request
(
action
,
reqbody
,
{
timeout
:
3000
,
// default 3000 ms
formatAction
:
true
,
// default true, format the action to Action
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
method
:
'GET'
,
// set the http method, default is GET
headers
:
{},
// set the http request headers
});
}
// async getCreateOrderNum() {
// var createOrderNum = await this.getUidStr(5, 36);//====================订单号生成
// return createOrderNum + "" + Date.now();
// }
// async getUidStr(len, radix) {
// var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
// var uuid = [], i;
// radix = radix || chars.length;
// if (len) {
// for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
// } else {
// var r;
// uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
// uuid[14] = '4';
// for (i = 0; i < 36; i++) {
// if (!uuid[i]) {
// r = 0 | Math.random() * 16;
// uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
// }
// }
// }
// return uuid.join('');
// }
}
module
.
exports
=
aliyunClient
;
bpo-admin/package.json
View file @
3edcab1d
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
"author"
:
"jy"
,
"author"
:
"jy"
,
"license"
:
"
ISC
"
,
"license"
:
"
ISC
"
,
"dependencies"
:
{
"dependencies"
:
{
"
@alicloud/pop-core
"
:
"^1.7.9"
,
"
MD5
"
:
"^1.3.0"
,
"
MD5
"
:
"^1.3.0"
,
"
after
"
:
"^0.8.2"
,
"
after
"
:
"^0.8.2"
,
"
ali-oss
"
:
"^4.12.2"
,
"
ali-oss
"
:
"^4.12.2"
,
...
...
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