Commit 93fd1bd6 by 王昆

gsb

parent 96cbbfb0
#!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com"
ADD xggsve-common/apps/xggsve-common/
WORKDIR /apps/xggsve-common/
ADD xggsve-merchant/apps/xggsve-merchant/
WORKDIR /apps/xggsve-merchant/
RUN cnpm install -S
CMD ["node","/apps/xggsve-common/main.js"]
CMD ["node","/apps/xggsve-merchant/main.js"]
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class BusinessscopeDao extends Dao {
constructor() {
super(Dao.getModelName(BusinessscopeDao));
}
async findListByDomicileIds(domicileIds) {
if (!domicileIds || domicileIds.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("id, domicile_id, businessType,");
sql.push("businessscope, isEnabled, created_at ");
sql.push("FROM d_businessscope");
sql.push("WHERE domicile_id IN (:domicileIds)");
return await this.customQuery(sql.join(" "), {
domicileIds: domicileIds
}) || [];
}
async findMapByDomicileIds(domicileIds) {
var result = {};
if (!domicileIds || domicileIds.length == 0) {
return result;
}
var list = await this.findListByDomicileIds(domicileIds);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
var domicileList = result[item.domicile_id] || [];
domicileList.push(item);
result[item.domicile_id] = domicileList;
}
return result;
}
async delById(id, t) {
var sql = "DELETE FROM d_businessscope WHERE id = :id";
return await this.customUpdate(sql, {
id: id
}, t);
}
async delByDomicileId(domicileId, t) {
var sql = "DELETE FROM d_businessscope WHERE domicile_id = :domicileId";
return await this.customUpdate(sql, {
domicileId: domicileId
}, t);
}
}
module.exports = BusinessscopeDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const fs = require("fs");
const settings = require("../../../../config/settings");
class CacheManager {
constructor() {
//await this.buildCacheMap();
this.buildCacheMap();
}
buildCacheMap() {
var self = this;
self.doc = {};
var cachePath = settings.basepath + "/app/base/db/cache/";
const files = fs.readdirSync(cachePath);
if (files) {
files.forEach(function (r) {
var classObj = require(cachePath + "/" + r);
if (classObj.name) {
self[classObj.name] = new classObj();
var refTmp = self[classObj.name];
if (refTmp.prefix) {
self.doc[refTmp.prefix] = refTmp.desc;
} else {
console.log("请在" + classObj.name + "缓存中定义prefix");
}
}
});
}
}
}
module.exports = CacheManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class DomicileDao extends Dao {
constructor() {
super(Dao.getModelName(DomicileDao));
}
async getList(isEnabled, attrs) {
attrs = attrs || "*"
var sql = [];
sql.push("SELECT ");
sql.push(attrs);
sql.push("FROM d_domicile");
if (isEnabled == 1) {
sql.push("WHERE isEnabled = 1");
}
return await this.customQuery(sql.join(" ")) || [];
}
async delById(id, t) {
var sql = "DELETE FROM d_domicile WHERE id = :id";
return await this.customUpdate(sql, {
id: id
}, t);
}
async findListByIds(ids) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("id, name, isEnabled, created_at ");
sql.push("FROM d_domicile");
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = DomicileDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class InvoicecontentDao extends Dao{
constructor(){
super(Dao.getModelName(InvoicecontentDao));
}
}
module.exports=InvoicecontentDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class DeliverDao extends Dao {
constructor() {
super(Dao.getModelName(DeliverDao));
}
async getList(isEnabled, attrs) {
attrs = attrs || "*"
var sql = [];
sql.push("SELECT ");
sql.push(attrs);
sql.push("FROM d_deliver");
if (isEnabled == 1) {
sql.push("WHERE isEnabled = 1");
}
return await this.customQuery(sql.join(" ")) || [];
}
async delById(id, t) {
var sql = "DELETE FROM d_deliver WHERE id = :id";
return await this.customUpdate(sql, {
id: id
}, t);
}
async findListByIds(ids) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("id, name, businessmenDivide, invoiceDivide, isEnabled, created_at ");
sql.push("FROM d_deliver");
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = DeliverDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("invoicecontent", {
name: DataTypes.STRING,
isEnabled: {
type:DataTypes.BOOLEAN,
allowNull:false,
defaultValue:false
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_invoicecontent',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class BusinessscopeService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(BusinessscopeService));
this.domicileDao = system.getObject("db.common.domicileDao");
}
async apiPage(params) {
try {
return await this.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSave(params) {
try {
return await this.save(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
try {
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDomicileList(params) {
try {
return await this.ListByDomicileId(params.domicileId);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDeleteByIds(params) {
var ids = params.ids || [];
try {
for(var id of ids) {
// 单条删除,方便以后有级联删除时使用事务
await this.delById(id);
}
return system.getResultSuccess(1);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// where: {
// id: id
// },
// attrs: ["id", "domicile_id", "businessType", "businessscope", "isEnabled", "created_at",],
// raw: true
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async ListByDomicileId(domicileId) {
var list = await this.dao.findListByDomicileIds([domicileId]) || [];
for(var item of list) {
this.handleDate(item, ["created_at"], null, -8);
}
await this.setDomicile(list);
return system.getResultSuccess(list);
}
async info(params) {
var id = params.id;
var sqlWhere = {
where: {
id: id
},
attributes: ["id", "domicile_id", "businessType", "businessscope", "isEnabled", "created_at",],
raw: true
};
var item = await this.dao.model.findOne(sqlWhere);
if(!item) {
return system.getResult(null, "经营范围不存在");
}
this.handleDate(item, ["created_at"], null, -8);
await this.setDomicile([item]);
return system.getResultSuccess(item);
}
async delById(id) {
if(!id) {
return;
}
await this.dao.delById(id);
return system.getResultSuccess(1);
}
async save(params) {
var domicileId = params.domicileId;
if (!domicileId) {
return system, getResult(null, domicileId);
}
var id = params.id;
var bsc;
if (id) {
bsc = await this.dao.findById(id);
} else {
bsc = {domicile_id: domicileId};
}
bsc.businessType = this.trim(params.businessType);
bsc.businessscope = this.trim(params.businessscope);
bsc.isEnabled = params.isEnabled == 1 ? true : false;
if(bsc.id) {
bsc = await bsc.save();
} else {
bsc = await this.dao.create(bsc);
}
return system.getResultSuccess(bsc);
}
async page(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.domicileId) {
where.domicile_id = params.domicileId;
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "domicile_id", "businessType", "businessscope", "isEnabled", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setDomicile(page.rows);
}
return system.getResultSuccess(page);
}
async setDomicile(rows) {
if(!rows || rows.length == 0) {
return;
}
var ids = [];
for(var item of rows) {
ids.push(item.domicile_id);
}
var map = await this.domicileDao.findMapByIds(ids);
for(var item of rows) {
item.domicile = map[item.domicile_id] || {};
this.handleDate(item.domicile, ["created_at"], null, -8);
}
}
}
module.exports = BusinessscopeService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
class CaptchaService {
constructor() {
this.redisClient = system.getObject("util.redisClient");
}
async apiGenerate(params) {
var key = uuidv4();
var options = {
size: 4,
noise: 1,
ignoreChars: '0o1i'
};
options.width = this.trim(params.width) || 120;
options.height = this.trim(params.height) || 32;
options.background = this.trim(params.background) || "#E8E8E8";
var captchaPrev = this.trim(params.captchaPrev);
var expire = Number(params.expire || 3 * 60)
try {
var cap = svgCaptcha.create(options);
console.log(cap);
await this.redisClient.setWithEx(key, cap.text, expire);
return system.getResultSuccess({
key: key,
text: cap.text,
captcha: cap.data,
});
} catch (error) {
return system.getResult(null, "接口异常:" + error.message);
}
}
async apiValidator(params) {
var key = this.trim(params.key);
var code = this.trim(params.code);
var cacheCode = await this.redisClient.get(key);
if(!cacheCode) {
return system.getResult(null, "验证码已过期,请点击重试");
}
if(code.toLowerCase() != cacheCode.toLowerCase()) {
await this.redisClient.delete(key);
return system.getResult(null, "验证码输入错误,清点击重试");
}
return system.getResultSuccess(1);
}
trim(o) {
if(!o) {
return "";
}
return o.toString().trim();
}
}
module.exports = CaptchaService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
// var settings = require("../../../../config/settings");
class InvoicecontentService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(InvoicecontentService));
// this.invoicecontentDao=system.getObject("db.common.invoicecontentDao");
}
async apiSave(params) {
try {
return await this.save(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiGetById(params) {
try {
if(!params.id){
return system.getResult(null, "参数错误");
}
return await this.getById(params.id);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiList(params) {
try {
console.log("--"+JSON.stringify(params));
return await this.invoiceList(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDelete(params) {
var ids = params.ids;
if (!ids || ids.length == 0) {
return system.getResult(null, "传入参数错误:ids=" + JSON.stringify(ids));
}
try {
try {
await this.bulkDelete(ids);
} catch (error) {
console.log(error);
}
return system.getResultSuccess(1);
} catch (error) {
return system.getResult(null, "接口异常");
}
}
/**--------------------------------------------------------------------- */
async getById(id){
let res = await this.dao.findById(id);
return system.getResultSuccess(res);
}
async save(params) {
let id = params.id;
let invoicecontent;
if(id){
invoicecontent=await this.dao.findById(id);
}else{
invoicecontent={};
}
invoicecontent.name=this.trim(params.name);
invoicecontent.isEnabled=(params.isEnabled)==1?true:false;
if(id){
await invoicecontent.save();
}else{
invoicecontent = await this.dao.create(invoicecontent);
}
return system.getResultSuccess(invoicecontent);
}
async bulkDelete(ids) {
if (!ids || ids.length == 0) {
return system.getResult(null, "删除失败");
}
await this.dao.bulkDelete(ids);
}
async invoiceList(params) {
console.log(JSON.stringify(params));
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.domicileId) {
where.domicile_id = params.domicileId;
}
if (params.name) {
where.name = {
[this.db.Op.like]: "%" + decodeURIComponent(params.name) + "%"
};
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "name", "isEnabled", "created_at", "updated_at", "deleted_at"];
let res = await this.dao.getPageList(currentPage, pageSize, where, orderby, attributes);
return res;
}
}
module.exports = InvoicecontentService;
## 公共接口服务
  1 [图片验证码](doc/common/captcha.md)
  2 [注册地](doc/common/domicile.md)
  3 [经营范围](doc/common/businessscope.md)
  4 [交付商](doc/deliver/deliver.md)
  5 [发票内容](doc/common/invoicecontent.md)
<a name="menu">目录</a>
1. [列表](#list)
1. [查询](#info)
1. [添加/修改](#save)
1. [删除](#del)
1. [按注册地查](#domicileList)
## **<a name="list"> 列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "businessscopePage",
"action_body": {
"currentPage": "1",
"pageSize": "3",
"domicileId": "" // 注册地id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 10,
"rows": [
{
"id": "12218127593000590", // 经营范围id
"domicile_id": "12706646858000580", // 注册地id
"businessType": "经营范围3", // 经营范围
"businessscope": "经营范围详情", // 经营范围详情
"isEnabled": 0, // 是否启用 0否 1是
"created_at": "2019-10-03 06:51:01", // 创建时间
"domicile": { // 注册地信息
"name": "杨庆菊1", // 注册地姓名
"isEnabled": 1, // 是否启用 0否 1是
"created_at": "2019-10-02 10:08:04"
}
},
]
},
"requestid": "f2bc255412d64cffb46d35b5c2f21ffe"
}
```
## **<a name="info"> 查询</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "businessscopeInfo",
"action_body": {
"id": "12218127593000590" // 经营范围id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"id": "12218127593000590", // 经营范围id
"domicile_id": "12706646858000580", // 注册地id
"businessType": "经营范围3", // 经营范围
"businessscope": "经营范围详情", // 经营范围详情
"isEnabled": 0, // 是否启用 0否 1是
"created_at": "2019-10-03 06:51:01", // 创建时间
"domicile": { // 注册地信息
"name": "杨庆菊1", // 注册地姓名
"isEnabled": 1, // 是否启用 0否 1是
"created_at": "2019-10-02 10:08:04"
}
},
"requestid": "436b027db2154f668c5f436040a28b9a"
}
```
## **<a name="save"> 添加/修改</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "businessscopeSave",
"action_body": {
"id": "", // id
"domicileId": "12706710830001318", // 注册地id
"businesssType": "经营范围1", // 经营范围
"businessscope": "经营范围详情1", // 经营范围详情
"isEnabled": 0
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {},
"requestid": "02da57850743496181fcd4705c09749e"
}
}
```
## **<a name="del"> 删除</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "businessscopeDelete",
"action_body": {
"ids": ["12218127708000700","12218127590000439","12218127733000865"]
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": 1,
"requestid": "51161e8d79614cb58de8edaa61a85766"
}
}
```
## **<a name="domicileList"> 按注册地查</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "businessscopeByDomicileId",
"action_body": {
"domicileId": "12706646858000580"
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
{
"id": "12218127593000590", // 经营范围id
"domicile_id": "12706646858000580", // 注册地id
"businessType": "经营范围3", // 经营范围
"businessscope": "经营范围详情", // 经营范围详情
"isEnabled": 0, // 是否启用 0否 1是
"created_at": "2019-10-03 06:51:01", // 创建时间
"domicile": { // 注册地信息
"name": "杨庆菊1", // 注册地姓名
"isEnabled": 1, // 是否启用 0否 1是
"created_at": "2019-10-02 10:08:04"
}
},
],
"requestid": "f2bc255412d64cffb46d35b5c2f21ffe"
}
```
<a name="menu">目录</a>
1. [获取图片验证码](#getCaptha)
## **<a name="getCaptha"> 获取图片验证码</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "getCaptha",
"action_body": {
"width": 120, // 验证码图片宽度 默认 120px
"height": 36, // 验证码图片高度 默认 36px
"background": "", // 验证码图片背景色,默认 #E8E8E8
"expire": 0 // 验证码过期时间(秒)
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"key": "3955eeef-606b-47af-ac7a-b3496b218f3e", // 图片验证码key
"captcha": "<svg>....</svg>" // 图片验证码
},
"requestid": "aca2b2767cef4a96b90a4d5d8e78becc"
}
```
<a name="menu">目录</a>
1. [全部注册地](#allList)
1. [名称列表](#namelist)
1. [列表](#list)
1. [查询](#info)
1. [添加/修改](#save)
1. [删除](#del)
## **<a name="allList"> 全部注册地</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "invoicecontentSave",
"action_body": {
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
{
"id": "12706710844001762", // id
"name": "杨庆菊12", // 注册地名称
"isEnabled": 1, // 是否启用 0否 1是
"created_at": "2019-10-03 03:54", // 创建时间
"businessscopeList": [ // 经营范围列表
{
"id": "12218127540000210", // 经营范围id
"domicile_id": "12706646858000580", // 注册地id
"businessType": "经营范围", // 经营范围
"businessscope": "经营范围详情", // 经营范围详情
"isEnabled": 0, // 是否启用 0否 1是
"created_at": "2019-10-03 06:50:08" // 创建时间
},
]
}
],
"requestid": "51161e8d79614cb58de8edaa61a85766"
}
```
## **<a name="namelist"> 名称列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "domicileNameList",
"action_body": {
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
{
"id": "12706646858000580", // 注册地id
"name": "杨庆菊1" // 注册地名称
},
{
"id": "12706647287000653",
"name": "杨庆菊2"
},
...
],
"requestid": "02da57850743496181fcd4705c09749e"
}
```
## **<a name="list"> 列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "domicilePage",
"action_body": {
"currentPage": "1",
"pageSize": "3",
"id": "" // 注册地id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"id": "12706710844001762", // id
"name": "杨庆菊12", // 注册地名称
"isEnabled": 1, // 是否启用 0否 1是
"created_at": "2019-10-03 03:54", // 创建时间
"businessscopeList": [ // 经营范围列表
{
"id": "12218127540000210", // 经营范围id
"domicile_id": "12706646858000580", // 注册地id
"businessType": "经营范围", // 经营范围
"businessscope": "经营范围详情", // 经营范围详情
"isEnabled": 0, // 是否启用 0否 1是
"created_at": "2019-10-03 06:50:08" // 创建时间
},
]
}
]
},
"requestid": "51161e8d79614cb58de8edaa61a85766"
}
```
## **<a name="save"> 添加/修改</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "domicileSave",
"action_body": {
"id": "", // id 空的时候添加,有具体id时修改
"name": "杨庆菊12", // 注册地名称
"isEnabled" : 1 // 是否启用 0否 1是
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {}
}
```
## **<a name="del"> 删除</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "domicileDelete",
"action_body": {
"ids": ["12218127593000590","12218127593000592"...] // 注册地id数组
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
\ No newline at end of file
<a name="menu">目录</a>
1. [添加/修改](#save)
2. [批量查询](#bulquery)
3. [单个查询](#query)
4. [删除](#delete)
## **<a name="save"> 保存发票内容</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "invoicecontentSave",
"action_body": {
"name": "总统孙",
"isEnabled": 1
}
}
```
#### 返回结果
```javascript
{
"status":0,
"msg":"success",
"data":{
"version":0,
"name":"总统孙",
"isEnabled":true,
"id":"11444111776000520",
"updated_at":"2019-10-10T08:51:00.939Z",
"created_at":"2019-10-10T08:51:00.939Z"
},
"requestid":"dce6dba445304dd8b043ecb913851a31"
}
```
## **<a name="invoicelist"> 发票列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
```
javascript
{
"action_process": "test",
"action_type": "invoiceList",
"action_body": {
currentPage:1, //非必填
pageSize:10,//非必填
name:xxx,//非必填(模糊查询)
id:xxx //非必填
}
}
```
#### 返回结果
```javascript
{
"count":2,
"rows":[
{
"id":"11444116222000933",
"name":"总统孙",
"isEnabled":1,
"created_at":"2019-10-10T10:05:06.000Z",
"updated_at":"2019-10-10T10:05:06.000Z",
"deleted_at":null
},
{
"id":"11444116214000855",
"name":"孙总统",
"isEnabled":1,
"created_at":"2019-10-10T10:04:58.000Z",
"updated_at":"2019-10-10T10:04:58.000Z",
"deleted_at":null
}
],
"requestid":"8557261ae1894ff2ba3a50b077f314e9"
}
```
## **<a name="invoicecontent"> 发票明细</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
```
javascript
{
"action_process": "test",
"action_type": "invoicecontent",
"action_body": {
id:xxx 
}
}
```
#### 返回结果
```javascript
{
"status":0,
"msg":"success",
"data":{
"id":"11444116222000933",
"name":"总统孙",
"isEnabled":true,
"created_at":"2019-10-10T10:05:06.000Z",
"updated_at":"2019-10-10T10:05:06.000Z",
"deleted_at":null,
"version":0
},
"requestid":"0a96be51bc2248469d8fb55d7b125dad"
}
```
## **<a name="invoicecontentDelete"> 删除发票</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "invoicecontentDelete",
"action_body": {
"ids":["xx","xxs"]
}
}
```
#### 返回结果
```javascript
{"status":0,"msg":"success","data":1,"requestid":"b225c65307be4a53be99885f4b579241"}
```
<a name="menu">目录</a>
1. [商户nameList](#nameList)
1. [新增/修改商户](#saveMerchant)
1. [商户列表](#merchantList)
1. [商户审核](#merchantAudit)
1. [商户签约](#merchantSign)
1. [查看签约](#showSign)
1. [签约列表](#signList)
1. [资金账户列表](#accountList)
1. [充值申请列表](#rechargeList)
1. [充值申请审核](#rechargeAudit)
1. [资金交易列表](#tradeList)
1. [资金流水列表](#processList)
## **<a name="nameList"> 商户nameList</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantCtl/nameList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": [
{
"id": 110361382269, // 商户id
"name": "司机宝" // 商户名称
},
{
"id": 110361384474,
"name": "测试公司录入1"
},
{
"id": 110361384475,
"name": "测试公司录入3"
},
{
"id": 110361384476,
"name": "546444544"
}
]
}
```
## **<a name="saveMerchant"> 新增/修改商户</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantCtl/saveMerchant]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": 110361384475, // 商户id,新增时为0, 修改时为当前修改的商户id
"name": "测试公司录入3", // 商户名称
"taxType": 1, // 纳税人类型 0一般纳税人 1小规模纳税人
"contactName": "宋毅", // 联系人姓名
"contactMobile": "13338383838", // 联系人手机
"contactEmail": "songyi@gongisbao.com", // 联系人邮箱
"taxNo": "sssssssss", // 纳税人识别号
"invoiceAddr": "朝来高科技产业园33333", // 开票地址
"invoiceMobile": "13838383838", // 开票电话
"accountName": "宋毅", // 开户名称
"accountPublic": "xxxx对公账户22222", // 对公账户
"mailAddr": "来广营", // 邮寄地址
"mailTo": "宋小毅", // 收件人
"mailMobile": "13838383838", // 收件电话
"ownerName": "宋大毅", // 客户经理姓名
"ownerMobile": "13838383838", // 客户经理电话
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
## **<a name="merchantList"> 商户列表</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantCtl/allList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": 1, // 当前页
"pageSize": 10, // 每页显示条数
"name": "测试公司", // 公司名称
"merchantId": 11111, // 商户id
"createdBegin": "", // 创建时间-开始
"createdEnd": "" // 创建时间-结束
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1, // 总数
"rows": [ // 商户列表
{
"id": 110361384475, // 商户id
"name": "测试公司录入3", // 商户名称
"taxType": 1, // 纳税人类型 0一般纳税人 1小规模纳税人
"contactName": "宋毅", // 联系人姓名
"contactMobile": "13338383838", // 联系人手机
"contactEmail": "songyi@gongisbao.com", // 联系人邮箱
"taxNo": "sssssssss", // 纳税人识别号
"invoiceAddr": "朝来高科技产业园33333", // 开票地址
"invoiceMobile": "13838383838", // 开票电话
"accountName": "宋毅", // 开户名称
"accountPublic": "xxxx对公账户22222", // 对公账户
"mailAddr": "来广营", // 邮寄地址
"mailTo": "宋小毅", // 收件人
"mailMobile": "13838383838", // 收件电话
"ownerName": "宋大毅", // 客户经理姓名
"ownerMobile": "13838383838", // 客户经理电话
"statusName": "待审核" // 商户状态名称
"status": 0, // 商户状态 0待审核 1待签约 2签约完成
"created_at": "2019-09-23 08:00", // 创建时间
},
]
}
}
```
## **<a name="merchantAudit"> 商户审核</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantCtl/merchantAudit]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": 110361382269, // 商户id
"ucname": "18600002222" // 商户登录帐号
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
## **<a name="merchantSign"> 添加/修改签约</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantsignedCtl/merchantSign]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"merchant_id": 110361382269, // 商户id
"nameA": "xxxxx有限公司", // 签约主体
"contractNo": "NO233332222", // 合同编码
"beginDate": "2019-08-22", // 合同开始时间
"endDate": "2020-08-22", // 合同结束时间
"serviceRate": "5.23", // 服务费率
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
## **<a name="showSign"> 查看签约</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantsignedCtl/showSign]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"merchant_id": 110361384474
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"merchant": {
"id": 110361384475, // 商户id
"name": "测试公司录入3", // 商户名称
},
"merchantSign": {
"merchant_id": 110361384474, // 商户id
"nameA": "xxxxx有限公司", // 签约主体
"contractNo": "NO233332222", // 合同编码
"beginDate": "2019-08-22T00:00:00.000Z", // 合同开始时间
"endDate": "2020-08-22T00:00:00.000Z", // 合同结束时间
"serviceRate": 5.23, // 服务费率
"created_at": "2019-09-23T12:08:38.000Z", // 创建时间
}
}
}
```
## **<a name="signList"> 签约列表</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantsignedCtl/signList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": 1, // 页码
"pageSize": 10, // 每页条数
"merchantId": 11111, // 商户id
"merchantName": "" // 商户名称
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 2,
"rows": [
{
"merchant": {
"id": 110361384475, // 商户id
"name": "测试公司录入3", // 商户名称
},
"merchantSign": {
"merchant_id": 110361384474, // 商户id
"nameA": "xxxxx有限公司", // 签约主体
"contractNo": "NO233332222", // 合同编码
"beginDate": "2019-08-22T00:00:00.000Z", // 合同开始时间
"endDate": "2020-08-22T00:00:00.000Z", // 合同结束时间
"serviceRate": 5.23, // 服务费率
"created_at": "2019-09-23T12:08:38.000Z", // 创建时间
}
},
]
}
}
```
## **<a name="accountList"> 资金账户</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantaccountCtl/accountList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": 1, // 页码
"pageSize": 10, // 每页条数
"merchantName": "" // 商户名称
"merchantId": "" // 商户id
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"id": 1,
"merchant_id": 110361382269, // 商户id
"frozen_amt": 120512852, // 冻结金额
"frozen_amt_y": "1205128.52", // 冻结金额(元)
"available_amt": 4879475646, // 可用金额
"available_amt_y": "48794756.46 " // 可用余额(元)
"created_at": "2019-09-10 13:27", // 创建时间
"merchantName": "司机宝", // 企业名称
}
]
}
}
```
## **<a name="rechargeList"> 充值申请列表</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantrechargeCtl/rechargeList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": 1,
"pageSize": 10,
"merchantName": " ", // 商户名称
"merchantId": "" // 商户id
"createdBegin": "", // 创建时间-开始
"createdEnd": "", // 创建时间-结束
"status": null // 状态 0待审核 1已入账 2审核失败
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 2,
"rows": [
{
"id": 1, // id, 审核时候传入
"merchant_id": 110361382269, // 商户id
"outTradeNo": "2", // 充值流水号
"voucher": "https://www.baidu.com/1.png", // 充值凭证
"amt": 100000, // 充值金额(分)
"amt_y": "1000", // 充值金额(元)
"statusName": "待审核", // 审核状态名称
"status": 0, // 审核状态
"remark": "", // 审核备注
"merchantName": "司机宝" // 商户名称
"auditUserName": "样情局" // 审核人
},
]
}
}
```
## **<a name="rechargeAudit"> 充值申请审核</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchantrechargeCtl/rechargeAudit]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": 3, // 充值id
"status": 1, // 审核状态 1已入账 2审核失败
"remark": "审核备注" // 审核备注 审核失败时必须填写
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
## **<a name="tradeList"> 资金交易列表</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchanttradeCtl/tradeList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": 1,
"pageSize": 10,
"merchantId":"", // 商户id
"invoiceApplyNo":"456456", // 发票申请号
"type":"", // 收支类型 1充值 2支出
"createdBegin":"", // 创建时间-开始
"createdEnd":"" // 创建时间-结束
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"id": 7, // id
"merchant_id": 110361382269, // 商户id
"merchantName": "司机宝", // 商户名称
"invoiceNo": "123123", // 发票编号
"invoiceApplyNo": "456456", // 发票申请号
"outTradeNo": "2", // 充值流水号
"amt": 100000, // 交易金额(分)
"amt_y": "1000" // 交易金额(元)
"balance": 4879525646, // 账户余额
"type": 2, // 收支类型 1充值 2支出
"businessTypeName": "增值费扣款", // 业务类型名称
"businessType": 20, // 业务类型 00服务费扣款 10个税扣款 20增值费扣款 30附加费扣款 90充值入账
"created_at": "2019-09-24 11:41", // 创建时间
}
]
}
}
```
## **<a name="processList"> 资金流水列表</a>**
[返回到目录](#menu)
##### URL
[/web/merchant/merchanttradeprocessCtl/processList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": 1,
"pageSize": 10,
"merchantId":"", // 商户id
"invoiceApplyNo":"456456", // 发票申请号
"busiType":"", // 业务类型 00开票冻结 10解冻扣款 20撤回发票退款 30审核驳回退款
"createdBegin":"", // 创建时间-开始
"createdEnd":"" // 创建时间-结束
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 4,
"rows": [
{
"id": 50, // id
"merchant_id": 110361382269, // 商户id
"merchantName": "司机宝", // 商户名号曾
"invoiceApplyNo": "100002", // 发票申请号
"amtType": "30", // 费用类型 00服务费 10个税 20增值费 30附加费
"amtTypeName": "附加费", // 费用类型名称
"amt": 0, // 流水金额(分)
"amt_y": "0", // 流水金额(元)
"frozen_amt": 120519881, // 账户冻结金额(分)
"frozen_amt_y": "1205198.81", // 账户冻结金额(元)
"available_amt": 4879468617, // 账户可用余额(分)
"available_amt_y": "48794686.17" // 账户可用余额(元)
"busiType": "00", // 业务类型 00开票冻结 10解冻扣款 20撤回发票退款 30审核驳回退款
"busiTypeName":"解冻扣款", // 业务类型名称
"created_at": "2019-09-20 03:16", // 创建时间
},
]
}
}
```
node_modules
.idea
npm-debug.log
dump.rdb
.DS_Store
/.project
.package-lock.json
*.csv
.vscode/launch.json
......@@ -72,25 +72,31 @@ class APIBase extends DocBase {
var app_id = req.headers["app_id"];
if (ispass) {
return result;
}//在白名单里面
if (app_id) {
// var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// if (signResult.status != 0) {
// result.status = system.signFail;
// result.msg = signResult.msg;
// }
}//验签
else if (appkey) {
appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
if (!appInfo || !appInfo.app) {
result.status = system.tokenFail;
result.msg = "请求头accesskey失效,请重新获取";
}
}//验证accesskey
else {
result.status = -1;
result.msg = "请求头没有相关访问参数,请验证后在进行请求";
}
//在白名单里面
// if (app_id) {
// appInfo = await this.cacheManager["ApiAppIdCheckCache"].cache(app_id, null, 3000);
// if (!appInfo) {
// result.status = system.appidFail;
// result.msg = "请求头app_id值失效,请重新获取";
// }
// // var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// // if (signResult.status != 0) {
// // result.status = system.signFail;
// // result.msg = signResult.msg;
// // }
// }//验签
// else if (appkey) {
// appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
// if (!appInfo || !appInfo.app) {
// result.status = system.tokenFail;
// result.msg = "请求头accesskey失效,请重新获取";
// }
// }//验证accesskey
// else {
// result.status = -1;
// result.msg = "请求头没有相关访问参数,请验证后在进行请求";
// }
return result;
}
async doexec(gname, methodname, pobj, query, req) {
......
......@@ -4,13 +4,14 @@ var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
this.domicileSve = system.getObject("service.common.domicileSve");
this.businessscopeSve = system.getObject("service.common.businessscopeSve");
this.captchaSve = system.getObject("service.common.captchaSve");
this.merchantSve = system.getObject("service.merchant.merchantSve");
this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
this.merchanttitleSve = system.getObject("service.merchant.merchanttitleSve");
this.merchantaddressSve = system.getObject("service.merchant.merchantaddressSve");
this.deliverSve = system.getObject("service.deliver.deliverSve");
this.invoicecontentSve = system.getObject("service.common.invoicecontentSve");
}
/**
* 接口跳转
......@@ -38,83 +39,107 @@ class ActionAPI extends APIBase {
async handleRequest(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// 图片验证码
case "getCaptha":
opResult = await this.captchaSve.apiGenerate(action_body);
// 商户api
case "infoList":
opResult = await this.merchantSve.apiInfoList(action_body);
break;
case "nameList":
opResult = await this.merchantSve.apiNameList(action_body);
break;
case "validCaptha":
opResult = await this.captchaSve.apiValidator(action_body);
case "addMerchant":
opResult = await this.merchantSve.apiAddMerchant(action_body);
break;
// 注册地
case "domicileNameList":
opResult = await this.domicileSve.apiNameList(action_body);
case "getById":
opResult = await this.merchantSve.apiGetMerchant(action_body);
break;
case "domicileTree":
opResult = await this.domicileSve.apiTree(action_body);
case "getMapByIds":
opResult = await this.merchantSve.apiGetMerchantMap(action_body);
break;
case "domicilePage":
opResult = await this.domicileSve.apiPage(action_body);
case "updMerchant":
opResult = await this.merchantSve.apiUpdMerchant(action_body);
break;
case "domicileSave":
opResult = await this.domicileSve.apiSave(action_body);
case "auditMerchant":
opResult = await this.merchantSve.apiAuditMerchant(action_body);
break;
case "domicileInfo":
opResult = await this.domicileSve.apiInfo(action_body);
case "queryMerchant":
opResult = await this.merchantSve.apiQueryMerchant(action_body);
break;
case "domicileDelete":
opResult = await this.domicileSve.apiDeleteByIds(action_body);
case "secretById":
opResult = await this.merchantSve.apiSecretById(action_body);
break;
// 经营范围
case "businessscopeByDomicileId":
opResult = await this.businessscopeSve.apiDomicileList(action_body);
// 商户签约api
case "saveMerchantSign":
opResult = await this.merchantsignedSve.apiSaveSign(action_body);
break;
case "businessscopePage":
opResult = await this.businessscopeSve.apiPage(action_body);
case "merchantSignInfo":
opResult = await this.merchantsignedSve.apiSignInfo(action_body);
break;
case "merchantSignList":
opResult = await this.merchantsignedSve.apiSignPage(action_body);
break;
// 商户抬头api
case "merchantTitleList":
opResult = await this.merchanttitleSve.apiTitlePage(action_body);
break;
case "businessscopeSave":
opResult = await this.businessscopeSve.apiSave(action_body);
case "merchantTitleInfo":
opResult = await this.merchanttitleSve.apiTitleInfo(action_body);
break;
case "businessscopeInfo":
opResult = await this.businessscopeSve.apiInfo(action_body);
case "merchantTitleSave":
opResult = await this.merchanttitleSve.apiSaveTitle(action_body);
break;
case "merchantTitleDefault":
opResult = await this.merchanttitleSve.apiSetDefault(action_body);
break;
case "businessscopeDelete":
opResult = await this.businessscopeSve.apiDeleteByIds(action_body);
case "getMerchantTitleDefault":
opResult = await this.merchanttitleSve.apiGetDefault(action_body);
break;
// 交付商
case "deliverAll":
opResult = await this.deliverSve.apiAll(action_body);
// 商户地址api
case "merchantAddressList":
opResult = await this.merchantaddressSve.apiAddressPage(action_body);
break;
case "deliverPage":
opResult = await this.deliverSve.apiPage(action_body);
case "merchantAddressInfo":
opResult = await this.merchantaddressSve.apiAddressInfo(action_body);
break;
case "deliverSave":
opResult = await this.deliverSve.apiSave(action_body);
case "merchantAddressSave":
opResult = await this.merchantaddressSve.apiSaveAddress(action_body);
break;
case "deliverInfo":
opResult = await this.deliverSve.apiInfo(action_body);
case "merchantAddressDefault":
opResult = await this.merchantaddressSve.apiSetDefault(action_body);
break;
case "deliverDelete":
opResult = await this.deliverSve.apiDeleteByIds(action_body);
case "getMerchantAddressDefault":
opResult = await this.merchantaddressSve.apiGetDefault(action_body);
break;
// 发票内容
case "invoicecontentSave":
opResult = await this.invoicecontentSve.apiSave(action_body);
// 资金账户
case "merchantAccountPage":
opResult = await this.merchantaccountSve.apiPage(action_body);
break;
case "merchantAccountInfo":
opResult = await this.merchantaccountSve.apiInfo(action_body);
break;
case "invoicecontentDelete":
opResult = await this.invoicecontentSve.apiDelete(action_body);
case "merchantAccountInfoByMerchantId":
opResult = await this.merchantaccountSve.apiInfoByMerchantId(action_body);
break;
case "invoiceList":
opResult = await this.invoicecontentSve.apiList(action_body);
// 商户充值api
case "merchantRechargePage":
opResult = await this.merchantrechargeSve.apiPage(action_body);
break;
case "invoicecontent":
opResult = await this.invoicecontentSve.apiGetById(action_body);
case "merchantRechargeAdd":
opResult = await this.merchantrechargeSve.apiAdd(action_body);
break;
case "merchantRechargeInfo":
opResult = await this.merchantrechargeSve.apiInfo(action_body);
break;
case "merchantRechargeAudit":
opResult = await this.merchantrechargeSve.apiAudit(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
var cacheBaseComp = null;
class MerchantCtl extends CtlBase {
constructor() {
super("merchant", CtlBase.getServiceName(MerchantCtl));
this.redisClient = system.getObject("util.redisClient");
this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
}
async testId(pobj, pobj2, req) {
this.service.create({
name: "tesxtid"
});
}
async nameList(pobj, pobj2, req) {
try {
var nameList = await this.service.nameList();
return system.getResultSuccess(nameList);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async allList(pobj, pobj2, req) {
return await this.queryList(pobj || {});
}
async queryList(condition) {
var condition = condition || {};
this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
try {
var page = await this.service.pageByCondition(condition);
return system.getResultSuccess(page);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async saveMerchant(pobj, pobj2, req) {
var merchant;
var merchantName = this.trim(pobj.name);
if(!merchantName) {
return system.getResult(null, "商户名称不能为空");
}
var id = Number(pobj.id);
if (id) {
merchant = await this.service.findById(id)
if (merchant.name != merchantName) {
var nameMerchant = await this.service.findOne({
name: merchantName
});
if (nameMerchant) {
return system.getResult(null, "商户名称【" + merchantName + "】已存在");
}
}
} else {
var nameMerchant = await this.service.findOne({
name: merchantName
});
if (nameMerchant) {
return system.getResult(null, "商户名称【" + merchantName + "】已存在");
}
merchant = {};
merchant.status = 0;
merchant.appSecret = system.getUid(32);
}
merchant.name = merchantName;
merchant.taxType = Number(pobj.taxType || 0);
merchant.contactName = this.trim(pobj.contactName);
merchant.contactMobile = this.trim(pobj.contactMobile);
merchant.contactEmail = this.trim(pobj.contactEmail);
merchant.taxNo = this.trim(pobj.taxNo);
merchant.invoiceAddr = this.trim(pobj.invoiceAddr);
merchant.invoiceMobile = this.trim(pobj.invoiceMobile);
merchant.accountName = this.trim(pobj.accountName);
merchant.accountPublic = this.trim(pobj.accountPublic);
merchant.mailAddr = this.trim(pobj.mailAddr);
merchant.mailTo = this.trim(pobj.mailTo);
merchant.mailMobile = this.trim(pobj.mailMobile);
merchant.ownerName = this.trim(pobj.ownerName);
merchant.ownerMobile = this.trim(pobj.ownerMobile);
try {
if (merchant.id) {
// 判断名称是否重复
await merchant.save();
} else {
merchant = await this.service.create(merchant);
}
this.merchantaccountSve.saveNew(merchant.id);
return system.getResultSuccess(merchant);
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async merchantAudit(pobj, pobj2, req) {
try {
var id = Number(pobj.id);
var ucname = this.trim(pobj.ucname);
if(!ucname) {
return system.getResult(null, "请输入系统登录帐号");
}
var merchant = await this.service.findById(id);
if(!merchant) {
return system.getResult(null, "商户不存在");
}
merchant.status = 1;
merchant.ucname = ucname;
// TODO 创建ucname账户
await merchant.save();
return system.getResultSuccess("");
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
}
module.exports = MerchantCtl;
\ No newline at end of file
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
var cacheBaseComp = null;
class MerchantaccountCtl extends CtlBase {
constructor() {
super("merchant", CtlBase.getServiceName(MerchantaccountCtl));
this.redisClient = system.getObject("util.redisClient");
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async accountList(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantName: this.trim(pobj.merchantName),
merchantId: pobj.merchantId
}
var page = await this.service.pageByCondition(condition);
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
}
module.exports = MerchantaccountCtl;
\ No newline at end of file
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
var cacheBaseComp = null;
class MerchantrechargeCtl extends CtlBase {
constructor() {
super("merchant", CtlBase.getServiceName(MerchantrechargeCtl));
this.redisClient = system.getObject("util.redisClient");
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async rechargeList(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantName: this.trim(pobj.merchantName),
merchantId: pobj.merchantId
}
this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
if(pobj.status) {
condition.status = Number(pobj.status);
}
var page = await this.service.pageByCondition(condition);
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async rechargeAudit(pobj, pobj2, req) {
try {
var loginUser = req.loginUser;
var id = Number(pobj.id);
var auditStatus = Number(pobj.status);
var remark = this.trim(pobj.remark);
if(auditStatus != 1 && auditStatus != 2) {
return system.getResult(null, "审核状态错误");
}
if(auditStatus == 2 && !remark) {
return system.getResult(null, "请填写审核备注");
}
var page = await this.service.audit(id, auditStatus, remark);
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
}
module.exports = MerchantrechargeCtl;
\ No newline at end of file
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
var cacheBaseComp = null;
class MerchantsignedCtl extends CtlBase {
constructor() {
super("merchant", CtlBase.getServiceName(MerchantsignedCtl));
this.redisClient = system.getObject("util.redisClient");
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async merchantSign(pobj, pobj2, req) {
try {
var merchantId = Number(pobj.merchant_id);
var merchant = await this.merchantSve.findById(merchantId);
if(!merchant) {
return system.getResult(null, "商户不存在");
}
if(merchant.status == 0) {
return system.getResult(null, "当前状态为【待审核】, 不允许签约");
}
var signObj = {
merchant_id : merchantId,
nameA : this.trim(pobj.nameA),
contractNo : this.trim(pobj.contractNo),
beginDate : this.trim(pobj.beginDate),
endDate : this.trim(pobj.endDate),
serviceRate : this.trim(pobj.serviceRate),
}
var msign = await this.service.findOne({merchant_id: merchantId});
if(!msign) {
msign = {};
}
msign.merchant_id = merchantId;
msign.nameA = this.trim(pobj.nameA);
msign.contractNo = this.trim(pobj.contractNo);
msign.beginDate = this.trim(pobj.beginDate);
msign.endDate = this.trim(pobj.endDate);
msign.serviceRate = Number(pobj.serviceRate);
if(msign.id) {
await msign.save();
} else {
msign = this.service.create(msign);
}
merchant.status = 2;
await merchant.save();
return system.getResultSuccess("");
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async showSign(pobj, pobj2, req) {
try {
var merchantId = Number(pobj.merchant_id);
var merchant = await this.merchantSve.getById(merchantId);
var msign = await this.service.getByMerchantId(merchantId);
return system.getResultSuccess({
merchant: merchant,
merchantSign: msign
});
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async signList(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantName: this.trim(pobj.merchantName),
merchantId: pobj.merchantId,
}
var page = await this.service.pageByCondition(condition);
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
// try {
// } catch (error) {
// return system.getResultFail(500, "接口异常:" + error.message);
// }
}
module.exports = MerchantsignedCtl;
\ No newline at end of file
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
var cacheBaseComp = null;
class MerchanttradeCtl extends CtlBase {
constructor() {
super("merchant", CtlBase.getServiceName(MerchanttradeCtl));
this.redisClient = system.getObject("util.redisClient");
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async tradeList(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantName: this.trim(pobj.merchantName),
merchantId: pobj.merchantId,
invoiceApplyNo: this.trim(pobj.invoiceApplyNo),
type: pobj.type,
createdBegin: this.trim(pobj.createdBegin),
createdEnd: this.trim(pobj.createdEnd),
}
this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
var page = await this.service.pageByCondition(condition);
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
// try {
// } catch (error) {
// return system.getResultFail(500, "接口异常:" + error.message);
// }
}
module.exports = MerchanttradeCtl;
\ No newline at end of file
......@@ -4,6 +4,7 @@ const settings = require("../../../config/settings");
class ApiAppIdCheckCache extends CacheBase {
constructor() {
super();
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
desc() {
return "应用中来访访问appid缓存";
......@@ -12,5 +13,11 @@ class ApiAppIdCheckCache extends CacheBase {
return settings.cacheprefix + "_verify_appid:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var item = await this.merchantDao.getItemByAppId(inputkey);
if (!item) {
return null;
}
return JSON.stringify(item);
}
}
module.exports = ApiAppIdCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class MerchantPushUrlCache extends CacheBase {
constructor() {
super();
this.merchantpushDao = system.getObject("db.merchant.merchantpushDao");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_merchantPushUrl:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var item = await this.merchantpushDao.getItemByMerchantId(inputkey);
if (!item) {
return null;
}
return JSON.stringify(item);
}
}
module.exports = MerchantPushUrlCache;
......@@ -321,6 +321,5 @@ class Dao {
ids: ids
}) || [];
}
}
module.exports = Dao;
\ No newline at end of file
const fs=require("fs");
const settings=require("../../../../config/settings");
class CacheManager{
constructor(){
//await this.buildCacheMap();
this.buildCacheMap();
}
buildCacheMap(){
var self=this;
self.doc={};
var cachePath=settings.basepath+"/app/base/db/cache/";
const files=fs.readdirSync(cachePath);
if(files){
files.forEach(function(r){
var classObj=require(cachePath+"/"+r);
self[classObj.name]=new classObj();
var refTmp=self[classObj.name];
if(refTmp.prefix){
self.doc[refTmp.prefix]=refTmp.desc;
}
else{
console.log("请在"+classObj.name+"缓存中定义prefix");
}
});
}
}
}
module.exports=CacheManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
const system = require("../../../system");
const Dao = require("../../dao.base");
class MerchantDao extends Dao {
constructor() {
super(Dao.getModelName(MerchantDao));
this.statusMap = {
"00": "待审核",
"10": "待签约",
"20": "签约完成",
}
this.taxTypeMap = {
"00": "一般纳税人",
"10": "小规模纳税人"
}
}
async nameList() {
var sql = "SELECT id, name FROM m_merchant";
return await this.customQuery(sql);
}
/**
* 获取商户信息
* @param {*} app_id appid
*/
async getItemByAppId(app_id) {
return this.model.findOne({
where: {
id: app_id
},
attributes: ["id",
"name", //商户名称
"taxType", //纳税人类型 0一般纳税人 1小规模纳税人
"contactName", //联系人姓名
"contactMobile", //联系人手机
"contactEmail", //联系人邮箱
"taxNo", //纳税人识别号
"invoiceAddr", //开票地址
"invoiceMobile", //开票电话
"accountName", //开户名称
"accountPublic", //对公账户
"mailAddr", //邮寄地址
"mailTo", //收件人
"mailMobile", //收件电话
"ownerId", //客户经理id
"ownerPath", //客户经理组织机构路径
"status", //订单状态 0待审核 1待签约 2签约完成
"ucname", //登录账号
"ucid", //登录账号用户id
"appSecret"
],
raw: true
});
}
async idsLikeName(name) {
var result = [];
if (!name || !name.trim()) {
return result;
}
var sql = "SELECT id FROM m_merchant WHERE name LIKE :name ";
var list = await this.customQuery(sql, {
name: "%" + name + "%"
});
if (list) {
for (var item of list) {
result.push(item.id);
}
}
return result;
}
async findMapByIds(ids, attrs) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM m_merchant where id IN (:ids) ";
var list = await this.customQuery(sql, {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = MerchantDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class MerchantaccountDao extends Dao {
constructor() {
super(Dao.getModelName(MerchantaccountDao));
}
// 冻结金额
// async frozenAmt(id, amt, t) {
// var sql = [];
// // UPDATE m_merchant_account SET banlance = banlance - :amt, frozen_amt = frozen_amt + :amt WHERE id = 1 AND banlance - :amt >= 0
// sql.push("UPDATE");
// sql.push("m_merchant_account");
// sql.push("SET");
// sql.push("banlance = banlance - :amt, frozen_amt = frozen_amt + :amt");
// sql.push("WHERE id = :id");
// sql.push("AND banlance - :amt >= 0");
// return await this.customUpdate(sql.join(" "), {
// id: id,
// amt: amt,
// }, t);
// }
// 撤回冻结
// async unFrozenAmt(id, amt, t) {
// var sql = [];
// // UPDATE m_merchant_account SET banlance = banlance - :amt, frozen_amt = frozen_amt + :amt WHERE id = 1 AND banlance - :amt >= 0
// sql.push("UPDATE");
// sql.push("m_merchant_account");
// sql.push("SET");
// sql.push("banlance = banlance + :amt, frozen_amt = frozen_amt - :amt");
// sql.push("WHERE id = :id");
// sql.push("AND frozen_amt - :amt >= 0");
// return await this.customUpdate(sql.join(" "), {
// id: id,
// amt: amt,
// }, t);
// }
// 解冻扣款
// async cutpayment(id, amt, t) {
// var sql = [];
// sql.push("UPDATE");
// sql.push("m_merchant_account");
// sql.push("SET");
// sql.push("frozen_amt = frozen_amt - :amt");
// sql.push("WHERE id = :id");
// sql.push("AND frozen_amt - :amt >= 0");
// return await this.customUpdate(sql.join(" "), {
// id: id,
// amt: amt,
// }, t);
// }
async inrBanlance(merchantId, amt, t) {
var sql = [];
sql.push("UPDATE");
sql.push("m_merchant_account");
sql.push("SET");
sql.push("banlance = banlance + :amt");
sql.push("WHERE merchant_id = :merchantId AND banlance + :amt > 0");
return await this.customUpdate(sql.join(" "), {
merchantId: merchantId,
amt: amt,
}, t);
}
async getByMerchantId(merchantId, channelId, attrs) {
if (!merchantId) {
return null;
}
var params = {
merchantId: merchantId,
channelId: channelId || 1,
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where merchant_id = :merchantId AND channel_id = :channelId LIMIT 1";
var list = await this.customQuery(sql, params);
return list && list.length > 0 ? list[0] : null;
}
}
module.exports = MerchantaccountDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class MerchantaddressDao extends Dao {
constructor() {
super(Dao.getModelName(MerchantaddressDao));
}
async updDefaultByMerchantId(merchantId, isDefault, t) {
var sql = [];
sql.push("UPDATE");
sql.push("m_merchant_address");
sql.push("SET");
sql.push("isDefault = :isDefault ");
sql.push("WHERE merchant_id = :merchantId");
return await this.customUpdate(sql.join(" "), {
merchantId: merchantId,
isDefault: isDefault
}, t);
}
async updDefaultById(id, isDefault, t) {
var sql = [];
sql.push("UPDATE");
sql.push("m_merchant_address");
sql.push("SET");
sql.push("isDefault = :isDefault ");
sql.push("WHERE id = :id");
return await this.customUpdate(sql.join(" "), {
id: id,
isDefault: isDefault
}, t);
}
async defaultByMerchantId(merchantId, t) {
var sql = "SELECT * FROM m_merchant_address WHERE merchant_id = :merchantId AND isDefault = 1";
var list = await this.customQuery(sql, {
merchantId: merchantId
}, t) || [null];
return list[0];
}
async listByMerchantId(merchantId, t) {
var sql = "SELECT * FROM m_merchant_address WHERE merchant_id = :merchantId";
return await this.customQuery(sql, {
merchantId: merchantId
}, t) || [];
}
async getDefaultByMerchantId(merchantId, t) {
var sql = "SELECT * FROM m_merchant_address WHERE merchant_id = :merchantId AND isDefault = 1";
var list = await this.customQuery(sql, {
merchantId: merchantId
}, t) || [];
return list && list.length > 0 ? list[0] : null;
}
}
module.exports = MerchantaddressDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class MerchantpushDao extends Dao {
constructor() {
super(Dao.getModelName(MerchantpushDao));
}
/**
* 获取推送地址
* @param {*} merchant_id 商户id
*/
async getItemByMerchantId(merchant_id) {
return this.model.findOne({
where: {
merchant_id: merchant_id
},
raw: true
});
}
async pushInfo(merchantId, field, params) {
var pushConfig = this.dao.findOne({
merchant_id: merchantId
}) || {};
var url = pushConfig[field];
if(!url) {
return;
}
var rs = await this.restClient.execPost(params, url);
var success = false;
if (rs.stdout) {
let rsData = JSON.parse(rs.stdout);
if (rsData.code == "0" || rsData.code == "0000") {
success = true;
}
}
await this.merchantpushlogDao.create({
merchant_id: merchantId,
api: url,
params: params,
rs: rs,
success: success
});
}
}
module.exports = MerchantpushDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class MerchantpushlogDao extends Dao{
constructor(){
super(Dao.getModelName(MerchantpushlogDao));
}
}
module.exports=MerchantpushlogDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
const system=require("../../../system");
const Dao=require("../../dao.base");
class MerchantrechargeDao extends Dao{
constructor(){
super(Dao.getModelName(MerchantrechargeDao));
this.statusMap = {
"00": "待审核",
"10": "已入账",
"20": "审核失败",
}
}
}
module.exports=MerchantrechargeDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
const system=require("../../../system");
const Dao=require("../../dao.base");
class MerchantsignedDao extends Dao{
constructor(){
super(Dao.getModelName(MerchantsignedDao));
}
}
module.exports=MerchantsignedDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
const system = require("../../../system");
const Dao = require("../../dao.base");
class MerchanttitleDao extends Dao {
constructor() {
super(Dao.getModelName(MerchanttitleDao));
}
async updDefaultByMerchantId(merchantId, isDefault, t) {
var sql = [];
// UPDATE m_merchant_title SET banlance = banlance - :amt, frozen_amt = frozen_amt + :amt WHERE id = 1 AND banlance - :amt >= 0
sql.push("UPDATE");
sql.push("m_merchant_title");
sql.push("SET");
sql.push("isDefault = :isDefault ");
sql.push("WHERE merchant_id = :merchantId");
return await this.customUpdate(sql.join(" "), {
merchantId: merchantId,
isDefault: isDefault
}, t);
}
async updDefaultById(id, isDefault, t) {
var sql = [];
sql.push("UPDATE");
sql.push("m_merchant_title");
sql.push("SET");
sql.push("isDefault = :isDefault ");
sql.push("WHERE id = :id");
return await this.customUpdate(sql.join(" "), {
id: id,
isDefault: isDefault
}, t);
}
async defaultByMerchantId(merchantId, t) {
var sql = "SELECT * FROM m_merchant_title WHERE merchant_id = :merchantId AND isDefault = 1";
var list = await this.customQuery(sql, {
merchantId: merchantId
}, t) || [];
return list[0];
}
async listByMerchantId(merchantId, t) {
var sql = "SELECT * FROM m_merchant_title WHERE merchant_id = :merchantId";
return await this.customQuery(sql, {
merchantId: merchantId
}, t) || [];
}
async getDefaultByMerchantId(merchantId, t) {
var sql = "SELECT * FROM m_merchant_title WHERE merchant_id = :merchantId AND isDefault = 1";
var list = await this.customQuery(sql, {
merchantId: merchantId
}, t) || [];
return list && list.length > 0 ? list[0] : null;
}
}
module.exports = MerchanttitleDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class MerchanttradeprocessDao extends Dao{
constructor(){
super(Dao.getModelName(MerchanttradeprocessDao));
}
}
module.exports=MerchanttradeprocessDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
......@@ -35,6 +35,35 @@ module.exports = (db, DataTypes) => {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchant", {
name: DataTypes.STRING(100),
taxType: DataTypes.STRING(4),
contactName: DataTypes.STRING(30),
contactMobile: DataTypes.STRING(30),
contactEmail: DataTypes.STRING(30),
invoiceValid: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
mustPay: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
orderPrice: DataTypes.BIGINT,
ownerName: DataTypes.STRING,
ownerMobile: DataTypes.STRING,
ownerId: DataTypes.STRING(32),
ownerPath: DataTypes.STRING(100),
status:{
type:DataTypes.STRING(4)
},
ucname: DataTypes.STRING(30),
ucid: DataTypes.STRING(32),
appSecret: DataTypes.STRING(64),//商户密钥信息,用于进行签名请求接口
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchantaccount", {
merchant_id: DataTypes.STRING(32),
channel_id: DataTypes.STRING(32),
banlance: DataTypes.BIGINT,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_account',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -2,53 +2,55 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("businessscope", {
domicile_id: DataTypes.STRING,
businessType: DataTypes.STRING,
businessscope: DataTypes.STRING,
isEnabled: {
return db.define("merchantaddress", {
merchant_id: DataTypes.STRING(32),
mailAddr: DataTypes.STRING(200),
mailTo: DataTypes.STRING(200),
mailMobile: DataTypes.STRING(200),
isDefault: {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: false
},
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_businessscope',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_address',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchantpush", {
merchant_id: DataTypes.STRING,
merchangeUpdate: DataTypes.STRING(200),
orderUpdate: DataTypes.STRING(200),
yichuzhizhao: DataTypes.STRING(200),
yikezhang: DataTypes.STRING(200),
yikaihu: DataTypes.STRING(200),
yishuiwubaodao: DataTypes.STRING(200),
yiyouji: DataTypes.STRING(200),
fapiaoshenhe: DataTypes.STRING(200),
fapiaokaiju: DataTypes.STRING(200),
fapiaoyouji: DataTypes.STRING(200),
fapiaowanshui: DataTypes.STRING(200),
chongzhishenhe: DataTypes.STRING(200),
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_push',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
......@@ -2,12 +2,16 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("domicile", {
name: DataTypes.STRING,
isEnabled: {
return db.define("merchantpushlog", {
merchant_id: DataTypes.STRING,
api: DataTypes.STRING(200),
params: DataTypes.STRING(5000),
rs: DataTypes.STRING(200),
success: {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: false
},
}, {
paranoid: true, //假的删除
underscored: true,
......@@ -15,7 +19,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_domicile',
tableName: 'm_merchant_push_log',
validate: {},
indexes: [
// Create a unique index on email
......
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchantrecharge", {
merchant_id: DataTypes.BIGINT,
voucher: DataTypes.STRING(300),
outTradeNo: DataTypes.STRING,
amt: DataTypes.BIGINT,
status: DataTypes.STRING(4),
remark: DataTypes.STRING(300),
auditUserName: DataTypes.STRING,
auditUserId: DataTypes.STRING,
auditTime: DataTypes.DATE,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_recharge',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchantsigned", {
merchant_id: DataTypes.STRING(32),
nameA: DataTypes.STRING(100),
contractNo: DataTypes.STRING(64),
beginDate: DataTypes.DATE,
endDate: DataTypes.DATE,
serviceRate: DataTypes.INTEGER,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_signed',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -2,55 +2,58 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("deliver", {
name: DataTypes.STRING,
businessmenDivide: DataTypes.INTEGER,
invoiceDivide: DataTypes.INTEGER,
remark: DataTypes.STRING,
return db.define("merchanttitle", {
isEnabled: {
merchant_id: DataTypes.STRING(32),
taxNo: DataTypes.STRING(64),
invoiceAddr: DataTypes.STRING(200),
invoiceMobile: DataTypes.STRING(30),
accountName: DataTypes.STRING(50),
accountPublic: DataTypes.STRING(50),
isDefault: {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: false
},
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_deliver',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_title',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchantuser", {
ucid: {
type:DataTypes.INTEGER,
allowNull: false,
},
ucname: {
type:DataTypes.STRING,
allowNull: false,
},
merchant_id: DataTypes.BIGINT,
lastLoginTime: {
type:DataTypes.DATE,
allowNull: true,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_merchant_user',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class MerchantService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchantService));
this.merchantaccountDao = system.getObject("db.merchant.merchantaccountDao");
this.merchanttitleDao = system.getObject("db.merchant.merchanttitleDao");
this.merchantaddressDao = system.getObject("db.merchant.merchantaddressDao");
this.merchantrechargeDao = system.getObject("db.merchant.merchantrechargeDao");
}
//查询商户
async apiGetMerchant(params) {
try {
return await this.getById(params.id, params.options);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiGetMerchantMap(params) {
try {
var map = await this.dao.findMapByIds(params.ids, params.attrs);
return system.getResultSuccess(map);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiAddMerchant(merchant) {
try {
merchant.orderPrice = merchant.orderPrice || 0;
merchant.ucname = "";
merchant.ucid = "";
merchant.appSecret = await this.getUidInfo(32);
return await this.addMerchant(merchant);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiUpdMerchant(merchant) {
try {
return await this.updMerchant(merchant);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiInfoList(params) {
try {
return await this.infoPage(params);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiQueryMerchant(params) {
try {
return await this.queryMerchant(params);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiNameList(params) {
try {
return await this.nameList(params);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiAuditMerchant(params) {
try {
return await this.auditMerchant(params);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiAuditMerchant(params) {
try {
return await this.auditMerchant(params);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
async apiSecretById(params) {
try {
return await this.secretById(params);
} catch (error) {
console.log(error)
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async secretById(params) {
var merchant = await this.dao.getById(params.id, "id, appSecret")
return system.getResultSuccess(merchant);
}
async nameList() {
var nameList = await this.dao.nameList();
return system.getResultSuccess(nameList);
}
async infoPage(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.merchantId) {
where.id = params.merchantId;
}
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd, true);
var orderby = [
["id", 'desc']
];
var attributes = ["id", "name", "taxType", "contactName", "contactMobile", "contactEmail",
"invoiceValid", "mustPay", "orderPrice", "ownerName", "ownerMobile", "status", "created_at"
];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
await this.dao.setRowCodeName(row, "status");
await this.dao.setRowCodeName(row, "taxType");
this.handleDate(row, ["created_at"], null, -8);
}
}
return system.getResultSuccess(page);
}
async addMerchant(merchant) {
var name = this.trim(merchant.name);
if (!name) {
return system.getResult(null, "请填写商户名称");
}
var isExist = await this.dao.findOne({
name: name
});
if (isExist) {
return system.getResult(null, "商户名称【" + name + "】已存在");
}
var title = merchant.title;
var address = merchant.address;
title.isDefault = true;
address.isDefault = true;
merchant.status = "00";
var self = this;
merchant = await self.db.transaction(async function (t) {
// 创建商户
merchant = await self.dao.create(merchant, t);
// 商户id赋值
title.merchant_id = merchant.id;
address.merchant_id = merchant.id;
// 创建账户
var account = await self.merchantaccountDao.create({
merchant_id: merchant.id,
channel_id: "1",
banlance: 0
}, t);
// 创建抬头
title = await self.merchanttitleDao.create(title, t);
// 创建收件地址
address = await self.merchantaddressDao.create(address, t);
merchant.accountList = [account];
merchant.titleList = [title];
merchant.addressList = [merchant.addressList];
return merchant;
});
return system.getResultSuccess();
}
async updMerchant(params) {
var id = this.trim(params.id);
var merchant = await this.dao.findById(id);
if (!merchant) {
return system.getResult(null, "商户不存在");
}
var name = this.trim(params.name);
if (!name) {
return system.getResult(null, "请填写商户名称");
}
var isExist = await this.dao.findOne({
name: name
});
if (isExist && isExist.id != id) {
return system.getResult(null, "商户名称【" + name + "】已存在");
}
merchant.name = name;
merchant.taxType = this.trim(params.taxType);
merchant.contactName = this.trim(params.contactName);
merchant.contactMobile = this.trim(params.contactMobile);
merchant.contactEmail = this.trim(params.contactEmail);
merchant.invoiceValid = params.invoiceValid ? true : false;
merchant.mustPay = params.mustPay ? true : false;
merchant.ownerName = this.trim(params.ownerName);
merchant.ownerMobile = this.trim(params.ownerMobile);
merchant.ownerId = this.trim(params.ownerId);
merchant.ownerPath = this.trim(params.ownerPath);
await merchant.save();
return system.getResultSuccess();
}
async auditMerchant(params) {
var id = this.trim(params.id);
var merchant = await this.dao.findById(id);
if (!merchant) {
return system.getResult(null, "商户不存在");
}
merchant.status = "10";
merchant.ucname = params.ucname;
merchant.ucid = params.ucid;
await merchant.save();
return system.getResultSuccess(merchant);
}
async getById(id, options) {
options = options || {};
var merchant = await this.dao.getById(id);
if (merchant) {
await this.dao.setRowCodeName(merchant, "status");
await this.dao.setRowCodeName(merchant, "taxType");
this.handleDate(merchant, ["created_at", "updated_at"], null, -8);
if(options.title) {
merchant.titleList = await this.merchanttitleDao.listByMerchantId(id);
}
if(options.address) {
merchant.addressList = await this.merchantaddressDao.listByMerchantId(id);
}
}
return system.getResultSuccess(merchant);
}
/**
* 查询商户信息 queryMerchant
* @param {*} params 查询条件{appid:XXX}
*/
async queryMerchant(id, options) {
//此处id没有获取到
let include=[];
if(options.title){
include.push({
association:this.dao.model.hasMany(this.merchanttitleDao.model,{
foreignKey:'merchant_id',targetKey:'id'
}),
required:false,
attributes:['titleNo','taxNo','invoiceAddr','invoiceMobile','accountName','accountPublic']
});
}
if(options.address){
include.push({
association:this.dao.model.hasMany(this.merchantaddressDao.model,{
foreignKey:'merchant_id',targetKey:'id'
}),
required:false,
attributes:['addressNo','mailAddr','mailTo','mailMobile']
});
};
let opt = {
where: {
id: id||"11064624194480427"
},
include,
attributes: [
`name`,
`taxType`,
`contactName`,
`contactEmail`,
`contactMobile`,
`invoiceValid`,
`mustPay`,
`status`,
`ownerName`,
`ownerMobile`,
`created_at`
],
raw: false
};
try {
var item = await this.dao.model.findOne(opt);
if (item) {
return system.getResultSuccess(item);
}else{
return system.getResult(null, "没有查询到相关数据");
}
} catch (error) {
return system.getResult(null, "没有查询到相关数据");
}
}
async pageByCondition(params) {
var currentPage = Number(params.currentPage || 0);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.name) {
where.name = {
[this.db.Op.like]: "%" + params.name + "%"
};
}
if (params.merchantId) {
where.id = params.merchantId;
}
if (params.owner_name) {
where.owner_name = {
[this.db.Op.like]: "%" + params.owner_name + "%"
};
}
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd, true);
var orderby = [
["id", 'desc']
];
var attributes = ["id", "name", "taxType", "contactName", "contactMobile", "contactEmail",
"taxNo", "invoiceAddr", "invoiceMobile", "accountName", "accountPublic",
"mailAddr", "mailTo", "mailMobile", "status",
"ownerName", "ownerMobile", "created_at"
];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
row.statusName = this.statusMap[row.status];
this.handleDate(row, ["created_at"], null, -8);
}
}
return page;
}
//操作平台--------------------------start
async createUser(userName, mobile, password) {
var param = {
app_id: req.app.id,
userName: userName,
mobile: mobile,
password: password || settings.defaultPassWord
}
var registerUrl = settings.paasUrl() + "api/auth/accessAuth/register";
}
//操作平台--------------------------end
}
module.exports = MerchantService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system=require("../../../system");
const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings")
class MerchantaccountService extends ServiceBase{
constructor(){
super("merchant", ServiceBase.getDaoName(MerchantaccountService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
async apiPage(params) {
try {
return await this.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
try {
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfoByMerchantId(params) {
try {
return await this.infoByMerchantId(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async info(params) {
var obj = await this.dao.getById(params.id);
if (obj) {
this.handleDate(obj, ["created_at", "updated_at"], null, -8);
await this.setMerchantName([obj], "id, name,");
}
return system.getResultSuccess(obj);
}
async infoByMerchantId(params) {
var obj = await this.dao.getByMerchantId(params.merchantId || params.merchant_id);
if (obj) {
this.handleDate(obj, ["created_at", "updated_at"], null, -8);
await this.setMerchantName([obj], "id, name");
}
return system.getResultSuccess(obj);
}
async page(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
var merchantIds ;
if (params.merchantName) {
merchantIds = await this.merchantDao.idsLikeName(params.merchantName);
if (!merchantIds || merchantIds.length == 0) {
return {count : 0, rows: []};
}
}
if(params.merchantId) {
var mid = Number(params.merchantId);
if(merchantIds) {
if(merchantIds.indexOf(mid) == -1) {
return {count : 0, rows: []};
} else {
merchantIds = [mid];
}
} else {
merchantIds = [mid];
}
}
if(merchantIds && merchantIds.length > 0) {
where.merchant_id = {
[this.db.Op.in]: merchantIds
};
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "merchant_id", "banlance", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setMerchantName(page.rows, "id, name")
}
return system.getResultSuccess(page);
}
async setMerchantName(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for (var row of rows) {
row.merchantName = (map[row.merchant_id] || {}).name || "";
}
}
async setMerchant(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for(var row of rows) {
row.merchant = map[row.merchant_id] || {};
}
}
async getMerchantMap(rows, attrs) {
if(!rows || rows.length == 0) {
return {};
}
var ids = [];
for(var row of rows) {
ids.push(row.merchant_id);
}
return await this.merchantDao.findMapByIds(ids, attrs);
}
}
module.exports=MerchantaccountService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class DomicileService extends ServiceBase {
class MerchantaddressService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(DomicileService));
this.businessscopeDao = system.getObject("db.common.businessscopeDao");
super("merchant", ServiceBase.getDaoName(MerchantaddressService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
async apiNameList(params) {
async apiAddressPage(params) {
try {
return await this.nameList();
return await this.addressPage(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiTree(params) {
async apiAddressInfo(params) {
try {
return await this.tree(params);
return await this.addressInfo(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiPage(params) {
async apiSaveAddress(params) {
try {
return await this.page(params);
return await this.saveAddress(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSave(params) {
async apiSetDefault(params) {
try {
return await this.save(params);
return await this.setDefault(params.id);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
async apiGetDefault(params) {
try {
return await this.info(params);
return await this.getDefault(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDeleteByIds(params) {
var ids = params.ids;
if (!ids || ids.length == 0) {
return system.getResult(null, "传入参数错误:ids=" + JSON.stringify(ids));
}
try {
for (var id of ids) {
try {
await this.delById(id);
} catch (error) {
console.log(error);
}
}
return system.getResultSuccess(1);
} catch (error) {
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async info(params) {
async saveAddress(params) {
var id = params.id;
if (!id) {
return system.getResult(null, "注册地不存在");
}
var sqlWhere = {
where: {
id: id
},
attributes: ["id", "name", "isEnabled", "created_at"],
raw: true
};
var item = await this.dao.model.findOne(sqlWhere);
if (!item) {
return system.getResult(null, "注册地不存在");
}
this.handleDate(item, ["created_at"], null, -8);
await this.setBusinessscopeList([item]);
return system.getResultSuccess(item);
}
async save(params) {
var id = params.id;
var domicile;
var merchantId = params.merchantId;
var address;
if (id) {
domicile = await this.dao.findById(id);
address = await this.findById(id);
} else {
domicile = {};
address = {
merchant_id: merchantId
};
}
domicile.name = this.trim(params.name);
domicile.isEnabled = params.isEnabled == 1 ? true : 0;
address.mailAddr = this.trim(params.mailAddr);
address.mailTo = this.trim(params.mailTo);
address.mailMobile = this.trim(params.mailMobile);
if (id) {
domicile = await domicile.save();
address = await address.save();
} else {
domicile = await this.dao.create(domicile);
address = await this.create(address);
}
return system.getResultSuccess(domicile);
}
async nameList() {
var list = await this.dao.getList(1, "id, name");
return system.getResultSuccess(list);
}
async tree(isEnabled) {
var tree = await this.dao.getList(isEnabled, "id, name, created_at");
if (tree) {
for (var row of tree) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setBusinessscopeList(tree);
if (params.isDefault) {
await this.dao.updDefaultByMerchantId(address.merchant_id, false);
await this.dao.updDefaultById(address.id, true);
}
return system.getResultSuccess(tree);
return system.getResultSuccess("");
}
async delById(id) {
if (!id) {
return system.getResult(null, "删除失败");
async getDefault(params) {
var merchantId = params.merchantId || params.merchant_id;
var obj = await this.dao.getDefaultByMerchantId(merchantId);
return system.getResultSuccess(obj);
}
async setDefault(id) {
var address = await this.dao.findById(id);
if (!address) {
return system.getResult(null, "地址不存在");
}
var self = this;
await this.db.transaction(async function (t) {
await self.dao.delById(id, t);
await self.businessscopeDao.delByDomicileId(id, t);
});
return system.getResultSuccess(1);
await this.dao.updDefaultByMerchantId(address.merchant_id, false);
await this.dao.updDefaultById(address.id, true);
return system.getResultSuccess();
}
async page(params) {
async addressPage(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.id > 0) {
where.id = params.id;
if (params.merchantId > 0) {
where.merchant_id = params.merchantId;
}
var orderby = [
["isDefault", 'desc'],
["id", 'desc']
];
var attributes = ["id", "name", "isEnabled", "created_at"];
var attributes = ["id", "merchant_id", "mailAddr", "mailTo", "mailMobile", "isDefault", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setBusinessscopeList(page.rows);
await this.setMerchantName(page.rows);
}
return system.getResultSuccess(page);
}
async setBusinessscopeList(rows) {
async addressInfo(params) {
var addr = await this.dao.getById(params.id);
if(addr) {
this.handleDate(addr, ["created_at", "updated_at"], null, -8);
}
return addr;
}
async setMerchant(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for (var row of rows) {
row.merchant = map[row.merchant_id] || {};
}
}
async setMerchantName(rows) {
var map = await this.getMerchantMap(rows);
for (var row of rows) {
row.merchantName = (map[row.merchant_id] || {}).name || "";
}
}
async getMerchantMap(rows, attrs) {
if (!rows || rows.length == 0) {
return rows;
return {};
}
var ids = [];
for (var item of rows) {
ids.push(item.id);
}
var bsmap = await this.businessscopeDao.findMapByDomicileIds(ids)
for (var row of rows) {
row.businessscopeList = bsmap[row.id] || [];
for (var item of row.businessscopeList) {
this.handleDate(item, ["created_at"], null, -8);
}
ids.push(row.merchant_id);
}
return await this.merchantDao.findMapByIds(ids, attrs);
}
}
module.exports = DomicileService;
module.exports = MerchantaddressService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
......
const system=require("../../../system");
const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings")
class MerchantService extends ServiceBase{
constructor(){
super("merchant", ServiceBase.getDaoName(MerchantService));
}
}
module.exports=MerchantService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system=require("../../../system");
const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings")
class MerchantpushlogService extends ServiceBase{
constructor(){
super("merchant", ServiceBase.getDaoName(MerchantpushlogService));
}
}
module.exports=MerchantpushlogService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class MerchantrechargeService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchantrechargeService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
this.merchantaccountDao = system.getObject("db.merchant.merchantaccountDao");
}
async apiAdd(params) {
try {
return await this.add(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiPage(params) {
try {
return await this.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
try {
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiAudit(params) {
try {
return await this.audit(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async add(params) {
var recharge = {
merchant_id: params.merchantId || params.merchant_id,
outTradeNo: this.trim(params.outTradeNo),
voucher: this.trim(params.voucher),
amt: Number(params.amt),
status: "00",
remark: "",
};
if (!recharge.outTradeNo) {
return system.getResult(null, "充值流水号不能为空");
}
if (!recharge.voucher) {
return system.getResult(null, "充值凭证不能为空");
}
if (!/^\d+$/.test(recharge.amt) || Number(recharge.amt) <= 0) {
return system.getResult(null, "充值金额只能为正整数");
}
var exists = await this.findOne({
merchant_id: recharge.merchant_id,
outTradeNo: recharge.outTradeNo,
});
if(exists) {
return system.getResult(null, "充值流水号已存在");
}
recharge = await this.dao.create(recharge);
return system.getResultSuccess();
}
async info(params) {
var recharge = await this.dao.getById(params.id);
if (recharge) {
await this.dao.setRowCodeName(recharge, "status");
this.handleDate(recharge, ["created_at", "updated_at"], null, -8);
await this.setMerchantName([recharge], "id, name");
}
return system.getResultSuccess(recharge);
}
async audit(params) {
var id = params.id;
var auditStatus = this.trim(params.status);
var remark = this.trim(params.remark);
var opUser = params.opUser;
var recharge = await this.dao.findById(id);
if (!recharge) {
return system.getResult(null, "充值申请不存在");
}
if(auditStatus != "10" && auditStatus != "20") {
return system.getResult(null, "审核状态错误");
}
if (recharge.status != "00") {
return system.getResult(null, "该申请已经被审核,不允许再次审核");
}
var self = this;
await this.db.transaction(async function (t) {
var updateParams = {
status: auditStatus,
remark: remark || "",
auditTime: new Date(),
auditUserName: opUser.ucname,
auditUserId: opUser.ucid,
}
// 审核
await self.dao.model.update(updateParams, {
where: {
id: recharge.id
},
transaction: t
});
if (auditStatus == "10") {
await self.merchantaccountDao.inrBanlance(recharge.merchant_id, recharge.amt, t);
var account = await self.merchantaccountDao.model.findOne({
channel_id: 0,
merchant_id: recharge.merchant_id
}, t);
}
});
return system.getResultSuccess();
}
async page(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.merchantId) {
where.merchant_id = params.merchantId;
}
if (params.status) {
where.status = params.status;
}
// 创建时间
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd, true);
var orderby = [
["id", 'desc']
];
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
if (page && page.rows) {
for (var row of page.rows) {
await this.dao.setRowCodeName(row, "status");
this.handleDate(row, ["created_at", "updated_at", "auditTime"], null, -8);
}
await this.setMerchantName(page.rows, "id, name");
}
return system.getResultSuccess(page);
}
async setMerchantName(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for (var row of rows) {
row.merchantName = (map[row.merchant_id] || {}).name || "";
}
}
async setMerchant(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for (var row of rows) {
row.merchant = map[row.merchant_id] || {};
}
}
async getMerchantMap(rows, attrs) {
if (!rows || rows.length == 0) {
return {};
}
var ids = [];
for (var row of rows) {
ids.push(row.merchant_id);
}
return await this.merchantDao.findMapByIds(ids, attrs);
}
}
module.exports = MerchantrechargeService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system=require("../../../system");
const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings")
class MerchantsignedService extends ServiceBase{
constructor(){
super("merchant", ServiceBase.getDaoName(MerchantsignedService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
async apiSaveSign(params) {
try {
return await this.saveSign(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSignInfo(params) {
try {
return await this.getByMerchantId(params.merchantId);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSignPage(params) {
try {
return await this.signPage(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async saveSign(params) {
var merchantId = params.merchantId;
var sign = await this.dao.findOne({merchant_id: merchantId});
var merchant = await this.merchantDao.findById(merchantId);
if(!sign) {
sign = {};
sign.merchant_id = merchantId;
}
sign.nameA = params.nameA;
sign.contractNo = params.contractNo;
sign.beginDate = params.beginDate;
sign.endDate = params.endDate;
sign.serviceRate = params.serviceRate;
if(sign.id) {
await sign.save();
} else {
sign = await this.create(sign);
}
merchant.status = "90";
await merchant.save();
return system.getResultSuccess();
}
async getByMerchantId(merchantId, attrs) {
var attrs = attrs || ["id", "merchant_id", "nameA", "contractNo", "beginDate", "endDate", "serviceRate", "created_at"];
var sign = await this.dao.model.findOne({
where: { merchant_id: merchantId }, attrs, raw: true
});
if(sign) {
this.handleDate(sign, ["beginDate", "endDate"], "YYYY-MM-DD");
this.handleDate(sign, ["created_at"], null, -8);
await this.setMerchantName([sign]);
}
return system.getResultSuccess(sign);
}
async signPage(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if(params.merchantId > 0) {
where.merchant_id = params.merchantId;
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "merchant_id", "nameA", "contractNo", "beginDate", "endDate", "serviceRate", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["beginDate", "endDate"], "YYYY-MM-DD");
this.handleDate(row, ["created_at"], null, -8);
}
await this.setMerchantName(page.rows);
}
return system.getResultSuccess(page);
}
async setMerchant(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for(var row of rows) {
row.merchant = map[row.merchant_id] || {};
}
}
async setMerchantName(rows) {
var map = await this.getMerchantMap(rows);
for(var row of rows) {
row.merchantName = (map[row.merchant_id] || {}).name || "";
}
}
async getMerchantMap(rows, attrs) {
if(!rows || rows.length == 0) {
return {};
}
var ids = [];
for(var row of rows) {
ids.push(row.merchant_id);
}
return await this.merchantDao.findMapByIds(ids, attrs);
}
}
module.exports=MerchantsignedService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class DeliverService extends ServiceBase {
class MerchanttitleService extends ServiceBase {
constructor() {
super("deliver", ServiceBase.getDaoName(DeliverService));
super("merchant", ServiceBase.getDaoName(MerchanttitleService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
async apiAll(params) {
async apiTitlePage(params) {
try {
return await this.allList();
return await this.titlePage(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiPage(params) {
async apiTitleInfo(params) {
try {
return await this.page(params);
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSave(params) {
async apiSaveTitle(params) {
try {
return await this.save(params);
return await this.saveTitle(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
async apiSetDefault(params) {
try {
return await this.info(params);
return await this.setDefault(params.id);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDeleteByIds(params) {
var ids = params.ids;
if(!ids || ids.length == 0) {
return system.getResult(null, "传入参数错误:ids=" + JSON.stringify(ids));
}
async apiGetDefault(params) {
try {
for(var id of ids) {
try {
await this.delById(id);
} catch (error) {
console.log(error);
}
}
return system.getResultSuccess(1);
return await this.getDefault(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async getDefault(params) {
var merchantId = params.merchantId || params.merchant_id;
var obj = await this.dao.getDefaultByMerchantId(merchantId);
return system.getResultSuccess(obj);
}
async info(params) {
var id = params.id;
var sqlWhere = {
where: {
id: id
},
attributes: ["id", "name", "businessmenDivide", "invoiceDivide", "isEnabled", "remark", "created_at"],
raw: true
};
var item = await this.dao.model.findOne(sqlWhere);
this.handleDate(item, ["created_at"], null, -8);
return system.getResultSuccess(item);
var title = await this.dao.getById(params.id);
if(title) {
this.handleDate(title, ["created_at"], null, -8);
await this.setMerchantName([title]);
}
return system.getResultSuccess(title);
}
async save(params) {
async saveTitle(params) {
var id = params.id;
var deliver;
var merchantId = params.merchantId;
var title;
if (id) {
deliver = await this.dao.findById(id);
title = await this.findById(id);
} else {
deliver = {};
title = {
merchant_id: merchantId
};
}
deliver.name = this.trim(params.name);
deliver.businessmenDivide = Number(params.businessmenDivide);
deliver.invoiceDivide = Number(params.invoiceDivide);
deliver.isEnabled = params.isEnabled == 1 ? true : 0;
deliver.remark = this.trim(params.remark);
title.taxNo = this.trim(params.taxNo);
title.invoiceAddr = this.trim(params.invoiceAddr);
title.invoiceMobile = this.trim(params.invoiceMobile);
title.accountName = this.trim(params.accountName);
title.accountPublic = this.trim(params.accountPublic);
if (id) {
deliver = await deliver.save();
title = await title.save();
} else {
deliver = await this.dao.create(deliver);
title = await this.create(title);
}
return system.getResultSuccess(deliver);
}
async allList() {
var list = await this.dao.getList(1, "id, name, businessmenDivide, invoiceDivide, remark");
return system.getResultSuccess(list);
if (params.isDefault) {
await this.dao.updDefaultByMerchantId(title.merchant_id, false);
await this.dao.updDefaultById(title.id, true);
}
return system.getResultSuccess(title);
}
async delById(id) {
if (!id) {
return system.getResult(null, "删除失败");
async setDefault(id) {
var title = await this.dao.findById(id);
if (!title) {
return system.getResult(null, "抬头不存在");
}
await this.dao.delById(id);
return system.getResultSuccess(1);
await this.dao.updDefaultByMerchantId(title.merchant_id, false);
await this.dao.updDefaultById(title.id, true);
return system.getResultSuccess();
}
async page(params) {
async titlePage(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.merchantId > 0) {
where.merchant_id = params.merchantId;
}
var orderby = [
["isDefault", 'desc'],
["id", 'desc']
];
var attributes = ["id", "name", "businessmenDivide", "invoiceDivide", "isEnabled", "remark", "created_at"];
var attributes = ["id", "merchant_id", "taxNo", "invoiceAddr", "invoiceMobile", "accountName", "accountPublic", "isDefault", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setMerchantName(page.rows);
}
return system.getResultSuccess(page);
}
async setMerchant(rows, attrs) {
var map = await this.getMerchantMap(rows, attrs);
for (var row of rows) {
row.merchant = map[row.merchant_id] || {};
}
}
async setMerchantName(rows) {
var map = await this.getMerchantMap(rows);
for (var row of rows) {
row.merchantName = (map[row.merchant_id] || {}).name || "";
}
}
async getMerchantMap(rows, attrs) {
if (!rows || rows.length == 0) {
return {};
}
var ids = [];
for (var row of rows) {
ids.push(row.merchant_id);
}
return await this.merchantDao.findMapByIds(ids, attrs);
}
}
module.exports = DeliverService;
module.exports = MerchanttitleService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
......
const system=require("../../../system");
const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings")
class MerchantuserService extends ServiceBase{
constructor(){
super("merchant", ServiceBase.getDaoName(MerchantuserService));
}
}
module.exports=MerchantuserService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
......@@ -164,10 +164,11 @@ class System {
}
return uuid.join('');
}
static microsetting() {
var path = "/api/op/action/springboard";
if (settings.env == "dev") {
var domain = "http://192.168.18.237";
var domain = "http://192.168.18.125";
return {
common: domain + ":3102" + path,
merchant: domain + ":3101" + path,
......@@ -176,12 +177,13 @@ class System {
payment: "" + path,
}
} else {
var odomain = "http://39.107.51.68"
return {
common: "http://xggsvecommon.gongsibao.com" + path,
merchant: "http://xggsvemerchant.gongsibao.com" + path,
order: "http://xggsveorder.gongsibao.com" + path,
invoice: "http://xggsveinvoice.gongsibao.com" + path,
payment: "http://xggsvepayment.gongsibao.com" + path,
common: odomain + ":8333" + path,
merchant: odomain + ":8335" + path,
order: odomain + ":8336" + path,
invoice: odomain + ":8338" + path,
payment: odomain + ":8337" + path,
}
}
}
......
......@@ -6,7 +6,7 @@ var settings={
db:10,
},
database:{
dbname : "xgg-common",
dbname : "xgg-merchant",
user: "write",
password: "write",
config: {
......
......@@ -4,36 +4,31 @@ var ENVINPUT = {
DB_PORT: process.env.DB_PORT,
DB_USER: process.env.DB_USER,
DB_PWD: process.env.DB_PWD,
DB_NAME: process.env.XGGSVECOMMON_DB_NAME,
DB_NAME: process.env.PAAS_DB_NAME,
REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT,
REDIS_PWD: process.env.REDIS_PWD,
REDIS_DB: process.env.XGGSVECOMMON_REDIS_DB,
REDIS_DB: process.env.PAAS_REDIS_DB,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
env: ENVINPUT.APP_ENV,
appKey: "40d64e586551405c9bcafab87266bb04",
paasKey: "wx76a324c5d201d1a4",
platformid: 1,
platformcompanyid: 1,
commonroleid: 1,
passroleid: 2,
tanentroleid: 1,
protocalPrefix: "http://",
appKey: "wx76a324c5d201d1a4",
secret: "f99d413b767f09b5dff0b3610366cc46",
salt: "%iatpD1gcxz7iF#B",
cacheprefix: "sjb",
usertimeout: 3600,//单位秒
defaultpwd: "987456",
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 3102,
defaultPassWord: "987456",
paasUrl: function () {
if (this.env == "dev") {
return "http://p.apps.com:3001/";
} else {
return "http://www.telecredit.cn/";
}
},
port: process.env.NODE_PORT || 4001,
reqEsAddr: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return "http://43.247.184.94:7200/";//localsettings.reqEsDevUrl;
return "http://43.247.184.94:7200/"; //localsettings.reqEsDevUrl;
} else {
return "http://43.247.184.94:7200/";
}
......@@ -44,15 +39,30 @@ var settings = {
},
opLogEsIsAdd: function () {
return 1;
}
},
},
homePage: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return localsettings.reqHomePageDevUrl;
} else {
return "http://boss.gongsibao.com/";
return "http://open.gongsibao.com/";
}
},
authUrl: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return localsettings.reqAuthUrl;
} else {
return "http://open.gongsibao.com/auth";
}
},
docUrl: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return localsettings.docUrl;
} else {
return "http://open.gongsibao.com/web/common/metaCtl/getApiDoc";
}
},
redis: function () {
......@@ -61,10 +71,10 @@ var settings = {
return localsettings.redis;
} else {
return {
host: "xxxxx",
port: xxxxx,
password: "xxxxx",
db: xx,
host: ENVINPUT.REDIS_HOST,
port: ENVINPUT.REDIS_PORT,
password: ENVINPUT.REDIS_PWD,
db: ENVINPUT.REDIS_DB,
};
}
},
......@@ -74,11 +84,11 @@ var settings = {
return localsettings.database;
} else {
return {
dbname: "xxxxx",
user: "xxxx",
password: "xxxxx",
dbname: ENVINPUT.DB_NAME,
user: ENVINPUT.DB_USER,
password: ENVINPUT.DB_PWD,
config: {
host: 'xxxxxx',
host: ENVINPUT.DB_HOST,
dialect: 'mysql',
operatorsAliases: false,
pool: {
......@@ -91,10 +101,11 @@ var settings = {
dialectOptions: {
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
} //设置MSSQL超时时间
},
};
}
}
};
module.exports = settings;
settings.ENVINPUT = ENVINPUT;
module.exports = settings;
\ No newline at end of file
## 商户服务接口
  1 [商户接口](doc/merchant/merchant.md)
  2 [签约管理](doc/merchant/signed.md)
  3 [资金账户](doc/merchant/account.md)
  4 [充值管理](doc/merchant/recharge.md)
  5 [抬头管理](doc/merchant/title.md)
  6 [地址管理](doc/merchant/address.md)
<a name="menu">目录</a>
1. [账户列表](#accountPage)
1. [账户信息](#accountInfo)
## **<a name="accountPage"> 账户列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantAccountPage",
"action_body": {
"currentPage": "1",
"pageSize": "10",
"merchantId": "" // 商户id
}
}
```
#### 返回结果
```javascript
{
"count": 11,
"rows": [
{
"id": "12055982262001419", // 账户ID
"merchant_id": "11064625945481089", // 商户id
"merchantName": "杨庆菊的公司11编辑", // 商户名称
"banlance": 0, // 账户余额(元)
"created_at": "2019-10-01 09:33:05", // 创建时间
},
...
],
"requestid": "f3771571a73f48b280dc11ae1e5a3cf1"
}
```
## **<a name="accountInfo"> 账户信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantAccountPage",
"action_body": {
"id": "" // 账户id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"id": "12055982262001419", // 账户ID
"merchant_id": "11064625945481089", // 商户id
"merchantName": "杨庆菊的公司11编辑", // 商户名称
"banlance": 0, // 账户余额(元)
"created_at": "2019-10-01 09:33:05", // 创建时间
"updated_at": "2019-10-01 09:33:05",
},
"requestid": "0816f983a4fc46b385ba645180766292"
}
```
<a name="menu">目录</a>
1. [地址列表](#addressList)
1. [地址信息](#addressInfo)
1. [添加/修改地址](#saveAddress)
1. [设置默认](#setDefault)
## **<a name="titleList"> 抬头列表</a>**
## **<a name="addressList"> 地址列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -50,9 +51,7 @@
```
## **<a name="saveTitle"> 添加/修改抬头</a>**
## **<a name="addressInfo"> 地址信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -61,19 +60,53 @@
{
"action_process": "test",
"action_type": "merchantAddressSave",
"action_type": "merchantAddressInfo",
"action_body": {
"id": "", // 地址id, 空的时候添加,有具体id时修改
"merchantId" :"11064624178480175", // 商户id
"mailAddr": "杨庆菊的地址5", // 邮寄地址
"mailTo": "杨庆菊的收件人6", // 收件人
"mailMobile": "杨庆菊的手机号27", // 收件人手机号
"isDefault" : true // 是否设置默认 false 否 true是
"id": "" // 商户id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"id": "12085609085001303", // 地址ID
"merchant_id": "11064625945481089", // 商户id
"merchantName": "杨庆菊的公司11编辑" // 商户名
"mailAddr": "杨庆菊客户的邮寄地址", // 邮寄地址
"mailTo": "杨庆菊客户的收件人", // 收件人
"mailMobile": "杨庆菊客户的收件人的手机号", // 收件电话
"isDefault": 1, // 是否默认 0否 1是
"created_at": "2019-10-01 09:33", // 创建时间
},
"requestid": "61964dc5e61d4326b9491ddfb77cd949"
}
```
## **<a name="save"> 添加/修改地址</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": "", // 地址id, 空的时候添加,有具体id时修改
"merchantId" :"11064624178480175", // 商户id
"mailAddr": "杨庆菊的地址5", // 邮寄地址
"mailTo": "杨庆菊的收件人6", // 收件人
"mailMobile": "杨庆菊的手机号27", // 收件人手机号
"isDefault" : 0 // 是否设置默认 0 否 1是
}
```
d
#### 返回结果
```javascript
......@@ -84,6 +117,7 @@ d
}
```
## **<a name="setDefault"> 设置默认</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
......
<a name="menu">目录</a>
1. [商户信息查询](#getById)
1. [商户信息查询](#info)
1. [批量查商户映射信息](#getMapByIds)
1. [商户名称列表](#nameList)
1. [添加商户](#addMerchant)
1. [编辑商户](#updMerchant)
1. [商户列表](#merchantList)
1. [商户列表](#infoList)
1. [商户审核](#auditMerchant)
1. [商户签约](#merchantSign)
1. [查看签约](#signInfo)
## **<a name="nameList"> 商户信息查询</a>**
## **<a name="info"> 商户信息查询</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -52,7 +49,6 @@
"status": "00", // 商户状态 00待审核 10待签约 90签约完成
"created_at": "2019-10-01 09:04", // 添加时间
"titleList": [ // 商户抬头列表
{
"id": "13661908986000576",
......@@ -63,6 +59,7 @@
"accountPublic": "杨庆菊客户的对公账户", // 对公账户
}
],
"addressList": [
{
"id": "12085607321000472",
......@@ -122,7 +119,7 @@
```
## **<a name="nameList"> 商户nameList</a>**
## **<a name="nameList"> 商户名称列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -177,7 +174,7 @@
"status": "00", // 商户状态 00待审核 10待签约 90签约完成
// 商户默认抬头信息
"title": {
"titleList": {
"taxNo": "杨庆菊客户的税号", // 纳税人识别号
"invoiceAddr": "杨庆菊客户的地址", // 开票地址
"invoiceMobile": "杨庆菊客户开票手机号", // 开票电话
......@@ -186,7 +183,7 @@
},
// 商户默认地址信息
"address": {
"addressList": {
"mailAddr": "杨庆菊客户的邮寄地址", // 邮寄地址
"mailTo": "杨庆菊客户的收件人", // 收件人
"mailMobile": "杨庆菊客户的收件人的手机号", // 收件电话
......@@ -242,11 +239,10 @@
{
"status": 0,
"msg": "success",
"data": {商户信息} // 返回商户信息
}
```
## **<a name="merchantList"> 商户列表</a>**
## **<a name="infoList"> 商户列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -269,32 +265,33 @@
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 10,
"rows": [
{
"id": "11064624202480602", // 商户id
"name": "杨庆菊的公司7", // 商户名称
"taxType": "00", // 纳税人类型
"taxTypeName": "一般纳税人", // 纳税人类型名称
"contactName": "杨庆菊", // 联系人姓名
"contactMobile": "杨庆菊手机号", // 联系人手机号
"contactEmail": "杨庆菊email", // 联系人邮箱
"invoiceValid": 1, // 开票申请校验 0否 1是
"mustPay": 1, // 校验订单支付 0否 1是
"ownerName": "客户经 杨庆菊", // 客户经理姓名
"ownerMobile": "客户经理杨庆菊手机", // 客户经理手机号
"statusName": "待审核", // 商户状态名称
"status": "00", // 商户状态 00待审核 10待签约 90签约完成
"created_at": "2019-10-01 09:04", // 添加时间
},
]
},
"requestid": "081f13fd9dd5441094487eeff6d0ff6f"
}
{
"status": 0,
"msg": "success",
"data": {
"count": 10,
"rows": [
{
"id": "11064624202480602", // 商户id
"name": "杨庆菊的公司7", // 商户名称
"taxType": "00", // 纳税人类型
"taxTypeName": "一般纳税人", // 纳税人类型名称
"contactName": "杨庆菊", // 联系人姓名
"contactMobile": "杨庆菊手机号", // 联系人手机号
"contactEmail": "杨庆菊email", // 联系人邮箱
"invoiceValid": 1, // 开票申请校验 0否 1是
"mustPay": 1, // 校验订单支付 0否 1是
"ownerName": "客户经 杨庆菊", // 客户经理姓名
"ownerMobile": "客户经理杨庆菊手机", // 客户经理手机号
"statusName": "待审核", // 商户状态名称
"status": "00", // 商户状态 00待审核 10待签约 90签约完成
"created_at": "2019-10-01 09:04", // 添加时间
},
]
},
"requestid": "081f13fd9dd5441094487eeff6d0ff6f"
}
```
......@@ -328,78 +325,3 @@
"requestid": "081f13fd9dd5441094487eeff6d0ff6f"
}
```
## **<a name="merchantSign"> 添加/修改签约</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "saveMerchantSign",
"action_body": {
"merchantId": "11064625945481089", // 商户id
"nameA": "杨庆菊的主体2222", // 签约主体
"contractNo": "杨庆菊录入合同2222号", // 合同编号
"beginDate": "2019-10-01", // 合同开始时间
"endDate": "2019-10-07", // 合同截至时间
"serviceRate": "332" // 服务费比率(例:3.32%, 这里需要传入300)
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
## **<a name="signInfo"> 查看签约</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantSignInfo",
"action_body": {
"merchantId": "11064625945481089" // 商户ID
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"merchant_id": "11064625945481089", // 商户ID
"nameA": "杨庆菊的主体2222", // 签约主体
"contractNo": "杨庆菊录入合同2222号", // 合同编号
"beginDate": "2019-10-01", // 合同开始时间
"endDate": "2019-10-07", // 合同截至时间
"serviceRateShow": 3.22 // 服务费比率显示
"serviceRate": 322 // 服务费比率(整数防止精度损失)
"created_at": "2019-10-01 11:35", // 创建时间
},
"requestid": "b6df9966b91f4567887a606686952fb0"
}
```
<a name="menu">目录</a>
1. [全部交付商](#allList)
1. [列表](#list)
1. [查询](#info)
1. [添加/修改](#save)
1. [删除](#del)
1. [充值申请](#add)
1. [充值列表](#list)
1. [充值信息](#info)
1. [充值审核](#audit)
## **<a name="allList"> 全部交付商</a>**
## **<a name="add"> 充值申请</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -14,11 +13,16 @@
{
"action_process": "test",
"action_type": "deliverAll",
"action_type": "merchantRechargeAdd",
"action_body": {
"amt": 100000, // 充值金额(分)
"merchantId": "11064622752480048", // 商户id
"outTradeNo":"杨庆菊2", // 第三方充值流水号
"voucher":"https://www.baidu.com/1.png" // 充值凭证
}
}
```
#### 返回结果
......@@ -26,36 +30,37 @@
{
"status": 0,
"msg": "success",
"data": [
{
"id": "13120681466000118", // 交付商编码
"name": "杨庆菊交付商", // 交付商名号曾
"businessmenDivide": 5000, // 个体户分成比例
"invoiceDivide": 3221, // 发票分成比例
"remark": "备注" // 备注
},
],
"requestid": "5026518c1b354582932e5222bab4a785"
"data": {
"merchant_id": "11064622752480048",
"outTradeNo": "杨庆菊2",
"voucher": "https://www.baidu.com/1.png",
"amt": 100000,
"status": "00",
"remark": "",
"id": "1789195248000236",
"created_at": "2019-10-05T05:26:25.752Z"
},
"requestid": "ffac0abe1e0e422288cf7be94686d428"
}
}
```
```
## **<a name="list"> 列表</a>**
## **<a name="list"> 充值列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "deliverPage",
"action_type": "merchantRechargeAdd",
"action_body": {
"currentPage": "1",
"pageSize": "10"
"amt": 100000, // 充值金额(分)
"merchantId": "11064622752480048", // 商户id
"outTradeNo":"杨庆菊2", // 第三方充值流水号
"voucher":"https://www.baidu.com/1.png" // 充值凭证
}
}
......@@ -63,33 +68,34 @@
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 12,
"rows": [
{
"id": "13120681635001335", // 交付商编码
"name": "杨庆菊交付商14", // 交付商名称
"businessmenDivide": 3025, // 个体户分成比例
"invoiceDivide": 2221, // 发票分成比例
"isEnabled": 0, // 是否可用 0否 1是
"remark": "备注" // 备注
"created_at": "2019-10-03 10:12:14" // 创建时间
},
]
"count": 4,
"rows": [
{
"id": "1789195248000236", // id
"merchant_id": "11064622752480048", // 商户id
"merchantName": "十一加班干这个事", // 商户名称
"outTradeNo": "杨庆菊2", // 充值流水号
"voucher": "https://www.baidu.com/1.png", // 充值凭证
"amt": 100000, // 充值金额(分)
"amt_y":1000, // 充值金额(元)
"status": "00", // 充值状态 00待审核 10已入账 20审核失败
"statusName": "待审核", // 充值状态名号曾
"remark": "", // 审核备注
"auditUserName": null, // 审核人姓名
"auditUserId": null, // 审核人id
"created_at": "2019-10-05 05:26:25", // 创建时间
"updated_at": "2019-10-05 05:26:25", // 更新时间
},
"requestid": "1e18fd911db84525a964e9a17d8c83d1"
}
```
],
"requestid": "f8401dfdefcc4809a86d3ae5c70eae12"
}
```
## **<a name="save"> 添加/修改</a>**
## **<a name="info"> 充值信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -98,33 +104,40 @@
{
"action_process": "test",
"action_type": "deliverSave",
"action_type": "merchantRechargeInfo",
"action_body": {
"id" : "", // 交付商编码 空的时候新增,具体id时修改
"name" : "杨庆菊交付商14", // 交付商名号曾
"businessmenDivide" : 3025, // 个体户分成比例
"invoiceDivide" : 2221, // 发票分成比例
"remark": "备注" // 备注
"isEnabled" : 0 // 是否可用 0否 1是
"id": "1789195248000236"
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {}
"data": {
"id": "1789195248000236", // id
"merchant_id": "11064622752480048", // 商户id
"merchantName": "十一加班干这个事", // 商户名称
"outTradeNo": "杨庆菊2", // 充值流水号
"voucher": "https://www.baidu.com/1.png", // 充值凭证
"amt": 100000, // 充值金额(分)
"amt_y":1000, // 充值金额(元)
"status": "00", // 充值状态 00待审核 10已入账 20审核失败
"statusName": "待审核", // 充值状态名号曾
"remark": "", // 审核备注
"auditUserName": null, // 审核人姓名
"auditUserId": null, // 审核人id
"created_at": "2019-10-05 05:26:25", // 创建时间
"updated_at": "2019-10-05 05:26:25", // 更新时间
},
"requestid": "c359d5fa943a44c99f9f68527c2effb9"
}
```
## **<a name="del"> 删除</a>**
## **<a name="audit"> 充值审核</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
......@@ -132,19 +145,23 @@
``` javascript
{
"action_process": "test",
"action_type": "deliverDelete",
"action_process": "sjb",
"action_type": "merchantRechargeAudit",
"action_body": {
"ids": ["12218127593000590","12218127593000592"...] // 交付商编码数组
"id": "1789198739000692", // 充值id
"status": "20", // 状态 10审核通过 20审核驳回
"remark":"测试接口", // 审核备注
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
"msg": "success",
"data": {},
"requestid": "c359d5fa943a44c99f9f68527c2effb9"
}
```
\ No newline at end of file
```
......@@ -66,7 +66,6 @@
"contractNo": "杨庆菊录入合同2222号", // 合同编号
"beginDate": "2019-10-01", // 合同开始时间
"endDate": "2019-10-07", // 合同截至时间
"serviceRateShow": 3.22 // 服务费比率显示
"serviceRate": 322 // 服务费比率(整数防止精度损失)
"created_at": "2019-10-01 11:35", // 创建时间
},
......@@ -109,7 +108,6 @@
"contractNo": "杨庆菊录入合同2222号", // 合同编号
"beginDate": "2019-10-01", // 合同开始时间
"endDate": "2019-10-07", // 合同截至时间
"serviceRateShow": 3.22 // 服务费比率显示
"serviceRate": 322 // 服务费比率(整数防止精度损失)
"created_at": "2019-10-01 11:35", // 创建时间
}
......
<a name="menu">目录</a>
1. [抬头列表](#titleList)
1. [抬头信息](#titleInfo)
1. [添加/修改抬头](#saveTitle)
1. [设置默认](#setDefault)
......@@ -50,7 +51,43 @@
```
## **<a name="titleInfo"> 抬头信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantTitleInfo",
"action_body": {
"id": "" // id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"id": "13661985486002511", // id
"merchant_id": "11064624178480175", // 商户id
"merchantName": "杨庆菊的公司2", // 商户名称
"taxNo": "杨庆菊客户的号", // 纳税人识别号
"invoiceAddr": "杨庆菊客户的地址", // 开票地址
"invoiceMobile": "杨庆菊客户开票手机号", // 开票电话
"accountName": "杨庆菊客户的账户名称", // 开户名称
"accountPublic": "杨庆菊客户的对公账户", // 对公账户
"isDefault": 0, // 是否默认 0否 1是
"created_at": "2019-10-02 06:18", // 创建时间
},
"requestid": "cf6320a1b615423b8a9ceb3b66b713f1"
}
```
## **<a name="saveTitle"> 添加/修改抬头</a>**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "xggsve-common",
"name": "xggsve-merchant",
"version": "1.0.0",
"description": "h5framework",
"main": "main.js",
......@@ -31,7 +31,6 @@
"express-session": "^1.15.6",
"gm": "^1.23.1",
"marked": "^0.7.0",
"md5": "^2.2.1",
"method-override": "^2.3.10",
"morgan": "^1.9.0",
"multer": "^1.3.0",
......
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