Commit fe641801 by 王昆

dd

parent 14d5466c
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class SaasnvoiceCtl extends CtlBase {
constructor() {
super();
this.saasmerchantSve = system.getObject("service.merchant.saasmerchantSve");
}
/**
* 发票信息管理
* @param {*} pobj2
* @param {*} pobj2
* @param {*} req
*/
async merchantTitleAddrPage (pobj1, pobj2, req){
try {
return this.saasmerchantSve.merchantTitleAddrPage(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
/**
* 发票信息修改
* @param {*} pobj2
* @param {*} pobj2
* @param {*} req
*/
async updateMerchantTitleAndAddr(pobj1, pobj2, req){
try {
if(!pobj1.id){
return system.getResult(null,`参数错误 ID 不能为空`);
}
return this.saasmerchantSve.updateMerchantTitleAndAddr(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
/**
* query invoice title&addr information
* @param {*} pobj1
* @param {*} pobj2
* @param {*} req
*/
async queryInvoiceTitleAndAddr(pobj1, pobj2, req){
try {
return this.saasmerchantSve.queryInvoiceTitleAndAddr(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
/**
* query invoice title&addr information
* @param {*} pobj1
* @param {*} pobj2
* @param {*} req
*/
async updateOrSaveTitleAndAddr(pobj1, pobj2, req){
try {
return this.saasmerchantSve.updateOrSaveTitleAndAddr(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
}
module.exports = SaasnvoiceCtl;
\ No newline at end of file
......@@ -97,5 +97,50 @@ class MerchantCtl extends CtlBase {
}
}
/**
* 商户抬头信息列表
* @param {*} pobj2
* @param {*} pobj2
* @param {*} req
*/
async merchantTitleAddrPage (pobj1, pobj2, req){
try {
return this.saasmerchantSve.merchantTitleAddrPage(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
/**
* query invoice title&addr information
* @param {*} pobj1
* @param {*} pobj2
* @param {*} req
*/
async queryInvoiceTitleAndAddr(pobj1, pobj2, req){
try {
return this.saasmerchantSve.queryInvoiceTitleAndAddr(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
/**
* query invoice title&addr information
* @param {*} pobj1
* @param {*} pobj2
* @param {*} req
*/
async updateOrSaveTitleAndAddr(pobj1, pobj2, req){
try {
return this.saasmerchantSve.updateOrSaveTitleAndAddr(pobj1);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
}
module.exports = MerchantCtl;
\ No newline at end of file
const system=require("../../../system");
const ServiceBase=require("../../svems.base");
var settings=require("../../../../config/settings");
class SaasInvoiceService extends ServiceBase{
constructor(){
super();
}
/**
* 发票信息管理
* @param {*} params
*/
async merchantTitleAddrPage(params){
return await this.callms("merchant","merchantTitleAddrPage",params);
}
/**
* 发票信息修改
* @param {*} params
*/
async updateMerchantTitleAndAddr(params){
return await this.callms("merchant","updateMerchantTitleAndAddr",params);
}
/**
* query invoice title&addr information
* @param {*} params
*/
async queryInvoiceTitleAndAddr(params){
return await this.callms("merchant","queryInvoiceTitleAndAddr",params);
}
/**
* 更新添加title&addr
* @param {*} params
*/
async updateOrSaveTitleAndAddr(params){
return await this.callms("merchant","updateOrSaveTitleAndAddr",params);
}
}
module.exports=SaasInvoiceService;
......@@ -25,7 +25,7 @@ class MerchantService extends ServiceBase {
async info(params) {
var rs = await this.callms("merchant", "mchtInfo", params);
if(rs.data && rs.data.sign) {
if (rs.data && rs.data.sign) {
this.transSignFields([rs.data.sign]);
await this.setChannel([rs.data]);
}
......@@ -39,7 +39,7 @@ class MerchantService extends ServiceBase {
async page(params) {
var rs = await this.callms("merchant", "mchtPage", params);
if(rs.data && rs.data.rows) {
if (rs.data && rs.data.rows) {
this.transSignFields(rs.data.rows);
await this.setChannel(rs.data.rows);
await this.setMain(rs.data.rows);
......@@ -54,50 +54,54 @@ class MerchantService extends ServiceBase {
async signInfo(params) {
var rs = await this.callms("merchant", "mchtSignInfo", params);
if(rs.data) {
if (rs.data) {
this.transSignFields([rs.data]);
}
return rs;
}
async setChannel(rows) {
if(!rows) {
if (!rows) {
return;
}
let channelIds = [];
for(let row of rows) {
if(row.channel_id) {
for (let row of rows) {
if (row.channel_id) {
channelIds.push(row.channel_id);
}
}
if(channelIds.length == 0) {
if (channelIds.length == 0) {
return;
}
let map = await this.channelSve.mapByIds({ids: channelIds}) || {};
let map = await this.channelSve.mapByIds({
ids: channelIds
}) || {};
map = map.data || {};
for(let row of rows) {
for (let row of rows) {
row.channel = map[row.channel_id] || {};
}
}
async setMain(rows) {
if(!rows) {
if (!rows) {
return;
}
let mainIds = [];
for(let row of rows) {
if(row.main_id) {
for (let row of rows) {
if (row.main_id) {
mainIds.push(row.main_id);
}
}
if(mainIds.length == 0) {
if (mainIds.length == 0) {
return;
}
let map = await this.mainSve.mapByIds({ids: mainIds}) || {};
let map = await this.mainSve.mapByIds({
ids: mainIds
}) || {};
map = map.data || {};
for(let row of rows) {
for (let row of rows) {
row.main = map[row.main_id] || {};
}
}
......@@ -122,18 +126,44 @@ class MerchantService extends ServiceBase {
}
let ids = [];
for(let row of rows) {
if(row.saas_merchant_id) {
for (let row of rows) {
if (row.saas_merchant_id) {
ids.push(row.saas_merchant_id);
}
}
let map = await this.mapByIds({ids: ids, attrs: "id, name, short_name"}) || {};
let map = await this.mapByIds({
ids: ids,
attrs: "id, name, short_name"
}) || {};
map = map.data || {};
for(let row of rows) {
for (let row of rows) {
row.merchant = map[row.saas_merchant_id] || {};
}
}
/**
* 发票信息管理
* @param {*} params
*/
async merchantTitleAddrPage(params) {
return await this.callms("merchant", "merchantTitleAddrPage", params);
}
/**
* query invoice title&addr information
* @param {*} params
*/
async queryInvoiceTitleAndAddr(params) {
return await this.callms("merchant", "queryInvoiceTitleAndAddr", params);
}
/**
* 更新添加title&addr
* @param {*} params
*/
async updateOrSaveTitleAndAddr(params) {
return await this.callms("merchant", "updateOrSaveTitleAndAddr", params);
}
}
module.exports = MerchantService;
\ No newline at end of file
......@@ -31,6 +31,10 @@
## 交易管理
  1 [订单管理](/doc/saas/trade.md)
## 发票管理
  1 [发票管理](/doc/saas/invoice.md)
## 其他
......
<a name="menu">目录</a>
1. [字典](#dics)
1. [查看商户抬头信息详情](#queryInvoiceTitleAndAddr)
1. [商户抬头信息列表](#merchantTitleAddrPage)
1. [更新或保存抬头地址信息](#updateOrSaveTitleAndAddr)
## **<a name="dics"> 字典</a>**
[返回到目录](#menu)
##### URL
[/web/saas/merchantCtl/dics]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
{
"id": 110361382269, // 商户id
"name": "司机宝" // 商户名称
"short_name": "去测1" // 简称
},
]
}
```
## **<a name="queryInvoiceTitleAndAddr"> 查看商户抬头信息详情</a>**
[返回到目录](#menu)
##### URL
[/web/saas/merchantCtl/queryInvoiceTitleAndAddr]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id":"11247613247000394"
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "操作成功",
"data": {
"saas_merchant_title": [
{
"id": "1311886627000462",
"saas_merchant_id": "11247613247000394",
"merchant_name": "舟山兰和有限公司",
"merchant_credit_code": "KHSDLKFJAFJ",
"merchant_tax_type": "00",
"merchant_addr": "河南信阳",
"merchant_mobile": "18833836395",
"merchant_bank": "北京银行栓秀支行",
"merchant_account": "zhousanlanhe",
"created_at": "2020-04-08T01:44:51.000Z",
"updated_at": "2020-04-08T01:49:05.000Z",
"deleted_at": null,
"version": 0
}
],
"saas_merchant_addr": [
{
"id": "12653007180000140",
"saas_merchant_id": "11247613247000394",
"mail_addr": "北京朝阳区国创元",
"mail_mobile": "010-4525821-44",
"mail_to": "张娇",
"created_at": "2020-04-08T01:44:51.000Z",
"updated_at": "2020-04-08T01:49:05.000Z",
"deleted_at": null,
"version": 0
}
]
},
"bizmsg": "empty",
"requestid": "8aa4673f14714bf7adacd04487075e9e"
}
```
## **<a name="merchantTitleAddrPage"> 商户抬头信息列表</a>**
[返回到目录](#menu)
##### URL
[/web/saas/merchantCtl/merchantTitleAddrPage]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage":1,
"pageSize":10,
"merchant_name":"舟山兰和有限公司" //选填 商户名称
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"id": "1311886627000462",
"saas_merchant_id": "11247613247000394",
"merchant_name": "舟山兰和有限公司",
"merchant_credit_code": "KHSDLKFJAFJ",
"merchant_tax_type": "00",
"merchant_addr": "河南信阳",
"merchant_mobile": "18833836395",
"merchant_bank": "北京银行栓秀支行",
"merchant_account": "zhousanlanhe",
"created_at": "2020-04-08 01:44:51",
"updated_at": "2020-04-08T01:49:05.000Z",
"deleted_at": null,
"version": 0
}
]
},
"requestid": "b8265578defd4d9983c1fcf5088e3bc2"
}
```
## **<a name="updateOrSaveTitleAndAddr"> 更新或保存抬头地址信息</a>**
[返回到目录](#menu)
##### URL
[/web/saas/merchantCtl/updateOrSaveTitleAndAddr]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id":"11247613247000394",
"merchant_name":"舟山兰和有限公司", //商户名称
"merchant_credit_code":"KHSDLKFJAFJ", // 统一社会信用代码
"merchant_tax_type":"00", //纳税人类型
"merchant_addr":"河南信阳", //地址
"merchant_mobile":"18833836395", //电话
"merchant_bank":"北京银行栓秀支行", //银行
"merchant_account":"zhousanlanhe", //账户
"mail_addr":"北京朝阳区国创元", //邮寄地址
"mail_mobile":"010-4525821-44", //邮寄电话
"mail_to":"张娇" //邮寄人
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"id": "1311886627000462",
"saas_merchant_id": "11247613247000394",
"merchant_name": "舟山兰和有限公司",
"merchant_credit_code": "KHSDLKFJAFJ",
"merchant_tax_type": "00",
"merchant_addr": "河南信阳",
"merchant_mobile": "18833836395",
"merchant_bank": "北京银行栓秀支行",
"merchant_account": "zhousanlanhe",
"created_at": "2020-04-08 01:44:51",
"updated_at": "2020-04-08T01:49:05.000Z",
"deleted_at": null,
"version": 0
}
]
},
"requestid": "b8265578defd4d9983c1fcf5088e3bc2"
}
```
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