Commit cecbe2e3 by wkliang

Merge branch 'esign-admin' of gitlab.gongsibao.com:jiangyong/zhichan into esign-admin

parents 0e871ac2 e412c834
var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class FeeTestCtl extends CtlBase {
constructor() {
super();
this.feeSve = system.getObject("service.fee.feeSve");
}
async ttttttttttt(qobj, pobj, req) {
// 创建账户
// let accountRes = await this.feeSve.createAccount({
// "app_id": "100001",
// "app_data_id": "3",
// "balance": 10000
// });
let infores = await this.feeSve.account({"account_id": 2});
let infobulkres = await this.feeSve.accountBulk({"account_ids": [2, '1']});
// let traderes = await this.feeSve.accountTrade({
// "account_id": "2",
// "trade_amt": 57,
// "trade_no": "112313213123123131",
// "trade_desc": "三要素验证"
// });
let mapres = await this.feeSve.tradeMapByIds({ids: ['12703897128000661', '12703897305000873', '12703897324000914']});
return system.getResultSuccess(this.loginDTO(req.loginUser));
}
}
module.exports = FeeTestCtl;
\ No newline at end of file
...@@ -46,6 +46,7 @@ class MerchantUserCtl extends CtlBase { ...@@ -46,6 +46,7 @@ class MerchantUserCtl extends CtlBase {
async auditMerchant(params, pobj2, req) { async auditMerchant(params, pobj2, req) {
try { try {
params.audit_user_id = req.loginUser.id;
return await this.merchantSve.auditMerchant(params); return await this.merchantSve.auditMerchant(params);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
......
var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class MerchantaccountCtl extends CtlBase {
constructor() {
super();
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
}
async reduceAccountBalance(params, pobj2, req) {
try {
return await this.merchantSve.reduceAccountBalance(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addordelavailable(params, pobj2, req) {
try {
return await this.merchantSve.addordelavailable(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantaccountCtl;
...@@ -32,6 +32,7 @@ class MerchantUserCtl extends CtlBase { ...@@ -32,6 +32,7 @@ class MerchantUserCtl extends CtlBase {
//充值审核 //充值审核
async auditMerchanttrade(params, pobj2, req) { async auditMerchanttrade(params, pobj2, req) {
try { try {
params.audit_user_id = req.loginUser.id;
return await this.merchanttradeSve.auditMerchanttrade(params); return await this.merchanttradeSve.auditMerchanttrade(params);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
...@@ -57,6 +58,9 @@ class MerchantUserCtl extends CtlBase { ...@@ -57,6 +58,9 @@ class MerchantUserCtl extends CtlBase {
} }
} }
module.exports = MerchantUserCtl; module.exports = MerchantUserCtl;
...@@ -27,6 +27,9 @@ class OrderCtl extends CtlBase { ...@@ -27,6 +27,9 @@ class OrderCtl extends CtlBase {
// TODO:需要去调用商户钱包 扣钱 // TODO:需要去调用商户钱包 扣钱
//TODO:可能需要商户的合同ID和合同名称
if(!pobj.contract_url){ if(!pobj.contract_url){
return system.getResult(null, `参数错误 业务合同不能为空`); return system.getResult(null, `参数错误 业务合同不能为空`);
} }
...@@ -36,8 +39,24 @@ class OrderCtl extends CtlBase { ...@@ -36,8 +39,24 @@ class OrderCtl extends CtlBase {
if(!pobj.live_end){ if(!pobj.live_end){
return system.getResult(null, `参数错误 结束时间不能为空`); return system.getResult(null, `参数错误 结束时间不能为空`);
} }
if(!pobj.hasOwnProperty('price')){
return system.getResult(null, `参数错误 订单金额不能为空`);
}
pobj.price=system.y2f(pobj.price);
if(pobj.product_type=='2'){//组合产品 需要 规格设成pricee
pobj.product_specifications=pobj.price;
}
if(pobj.product_type=='1'){ //如果是单个产品 需要转化单价
pobj.product_unit_price = system.y2f(pobj.product_unit_price);
}
//保存 //保存
let res = await this.orderSve.saveEorder(pobj); let res = await this.orderSve.saveEorder(pobj);
if(res.status==0 && res.data && res.data.price && res.data.product_type){
res.data.price = system.f2y(res.data.price) || 0;
if(res.data.product_type=='2'){ //如果是组合产品
res.data.product_specifications = system.f2y(res.data.product_specifications) || 0;
}
}
return system.getResult(res); return system.getResult(res);
}catch (e) { }catch (e) {
console.log(e); console.log(e);
...@@ -61,11 +80,11 @@ class OrderCtl extends CtlBase { ...@@ -61,11 +80,11 @@ class OrderCtl extends CtlBase {
if(!pobj.audit_status){ if(!pobj.audit_status){
return system.getResult(null, `参数错误 审核状态不能为空`); return system.getResult(null, `参数错误 审核状态不能为空`);
} }
pobj.audit_user_id=req.loginUser.id; //获取审核人
let res = await this.orderSve.auditEorder(pobj); let res = await this.orderSve.auditEorder(pobj);
//TODO:审核订单成功之后 //TODO:审核订单成功之后
if(res.status==0){ if(res.status==0){
pushMerchantTrade(pobj); this.pushMerchantTrade(pobj);
} }
return system.getResult(res); return system.getResult(res);
}catch (e) { }catch (e) {
...@@ -84,10 +103,10 @@ class OrderCtl extends CtlBase { ...@@ -84,10 +103,10 @@ class OrderCtl extends CtlBase {
console.log(`推送流水失败 订单信息获取异常`); console.log(`推送流水失败 订单信息获取异常`);
} }
if(params.audit_status=='20'){ //订单审核成功 if(params.audit_status=='20'){ //订单审核成功
//TODO:推送给赵大哥
} }
if(params.audit_status=='30'){ //订单审核失败 if(params.audit_status=='30'){ //订单审核失败
//TODO:推送给赵大哥
} }
} }
...@@ -157,4 +176,4 @@ class OrderCtl extends CtlBase { ...@@ -157,4 +176,4 @@ class OrderCtl extends CtlBase {
} }
} }
module.exports = ProductCtl; module.exports = OrderCtl;
\ No newline at end of file \ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class FeeService extends ServiceBase {
constructor() {
super();
// 引擎不可以引用任何
}
/**
* 创建计费账户
* @param params
* app_id: 电子签订单 100001
* app_data_id: 订单id
* balance: 余额,整数(分或份)
* @returns {status:0, msg: "", data: {account_id: 1111}}
*/
async createAccount(params) {
try {
return await this.callms("engine_fee", "accountCreate", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 账户查询
* @param params
* account_id: 账户id
* @returns
*/
async account(params) {
try {
return await this.callms("engine_fee", "accountInfo", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 账户查询批量
* @param params
* account_ids: 账户id
* @returns
*/
async accountBulk(params) {
try {
return await this.callms("engine_fee", "accountBulkInfo", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 账户查询批量
* @param params
* {
* "account_id": "1",
* "trade_amt": 57,
* "trade_no": "123314",
* "trade_desc": "三要素验证"
* }
* +
* account_ids: 账户id
* @returns
*/
async accountTrade(params) {
try {
return await this.callms("engine_fee", "accountTrade", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* @param params
* {
* "currentPage": 1,
* "pageSize": 10,
* "account_id": "1",
* "trade_type": "1",
* "trade_no": "123313",
* "tradeTimeBegin": "2020-06-26 04:21:31",
* "tradeTimeEnd": "2020-06-26 05:11:31"
* }
* @returns
*/
async accountTradePage(params) {
try {
return await this.callms("engine_fee", "accountTrade", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* account_id
* @param params
* {
* "account_id": "1",
* "trade_type": "1",
* "trade_nos": ['1','2'],
* }
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}|{msg: string, data, bizmsg: *|string, status: number}|any|undefined>}
*/
async tradeMapByIds(params) {
try {
return await this.callms("engine_fee", "tradeMapByIds", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = FeeService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class MerchantaccountService extends ServiceBase {
constructor() {
super();
}
async reduceAccountBalance(params) {
try {
return await this.callms("sve_merchant", "reduceAccountBalance", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addordelavailable(params) {
try {
return await this.callms("sve_merchant", "addordelavailable", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantaccountService;
...@@ -189,18 +189,18 @@ class System { ...@@ -189,18 +189,18 @@ class System {
// 产品引擎 // 产品引擎
engine_product: local + ":3571" + path, engine_product: local + ":3571" + path,
// 计费引擎 // 计费引擎
engine_fee: local + ":3103" + path, engine_fee: local + ":3572" + path,
// 认证引擎 // 认证引擎
engine_auth: local + ":3103" + path, engine_auth: local + ":3573" + path,
// 签约引擎 // 签约引擎
engine_sign: local + ":3103" + path, engine_sign: local + ":3574" + path,
// 用户服务 // 用户服务
sve_uc: dev + ":3651" + path, sve_uc: dev + ":3651" + path,
// 商户服务 // 商户服务
sve_merchant: local + ":3652" + path, sve_merchant: local + ":3652" + path,
// 订单服务 // 订单服务
sve_order: dev + ":3653" + path, sve_order: local + ":3653" + path,
} }
} else { } else {
return { return {
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
## 商户 ## 商户
  1 [商户接口](/doc/merchant/merchant.md)   1 [商户接口](/doc/merchant/merchant.md)
## 商户
  1 [商户接口](/doc/merchant/chantaccount.md)
  2 [商户账号](/doc/merchant/merchantuser.md)   2 [商户账号](/doc/merchant/merchantuser.md)
......
[返回主目录](/doc)
<a name="menu">目录</a>
1. [减少余额](#reduceAccountBalance)
1. [加减可用余额](#addordelavailable)
1. [代客下单流水](#valetorder)
## **<a name="reduceAccountBalance"> 减少余额</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantaccountCtl/reduceAccountBalance]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"merchant_id":"12805595251001601", //商户ID
"amount": 10000 //金额
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
null,
1
],
"requestid": "67931cbaf71d4a7c8e70db387cf6adfd"
}
```
## **<a name="addordelavailable"> 加减可用余额</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantaccountCtl/addordelavailable]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"merchant_id":"12805595251001601", //商户ID
"amount":-10000 //金额 正数为加 负数为减
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
null,
1
],
"requestid": "67931cbaf71d4a7c8e70db387cf6adfd"
}
```
## **<a name="valetorder"> 代课下单流水</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchanttradeCtl/valetorder]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"merchant_id":"12805595251001601", //商户ID
"trade_data_id":"xxxxx", //流水号
"amount":100, //交易金额
"trade_voucher":"凭证" //交易凭证
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"version": 0,
"merchant_id": "12805595251001601",
"trade_time": "2020-06-29T08:27:00.000Z",
"amount": 10000,
"trade_voucher": "凭证",
"trade_type": 1,
"pay_type": 2,
"amount_type": 1,
"trade_data_id": "20200630174148",
"available_amount": 10000,
"balance_amount": 12405600,
"id": "13685748088000638",
"updated_at": "2020-06-30T09:41:48.920Z",
"created_at": "2020-06-30T09:41:48.920Z"
},
"requestid": "d765cf11463d44b4a76edbb6a069346a"
}
```
{
"lockfileVersion": 1
}
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