Commit 00ed1a86 by 王昆

gsb

parent 7afb4ff4
#!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com"
ADD xggsve-merchant/apps/xggsve-merchant/
WORKDIR /apps/xggsve-merchant/
ADD xggsve-order/apps/xggsve-order/
WORKDIR /apps/xggsve-order/
RUN cnpm install -S
CMD ["node","/apps/xggsve-merchant/main.js"]
CMD ["node","/apps/xggsve-order/main.js"]
......
node_modules
.idea
npm-debug.log
dump.rdb
.DS_Store
/.project
.package-lock.json
*.csv
.vscode/launch.json
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
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");
}
/**
* 接口跳转
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springboard(pobj, qobj, req) {
var result;
if (!pobj.action_process) {
return system.getResult(null, "action_process参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "action_type参数不能为空");
}
try {
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
} catch (error) {
console.log(error);
}
return result;
}
async handleRequest(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// 商户api
case "infoList":
opResult = await this.merchantSve.apiInfoList(action_body);
break;
case "nameList":
opResult = await this.merchantSve.apiNameList(action_body);
break;
case "addMerchant":
opResult = await this.merchantSve.apiAddMerchant(action_body);
break;
case "getById":
opResult = await this.merchantSve.apiGetMerchant(action_body);
break;
case "getMapByIds":
opResult = await this.merchantSve.apiGetMerchantMap(action_body);
break;
case "updMerchant":
opResult = await this.merchantSve.apiUpdMerchant(action_body);
break;
case "auditMerchant":
opResult = await this.merchantSve.apiAuditMerchant(action_body);
break;
case "queryMerchant":
opResult = await this.merchantSve.apiQueryMerchant(action_body);
break;
case "secretById":
opResult = await this.merchantSve.apiSecretById(action_body);
break;
// 商户签约api
case "saveMerchantSign":
opResult = await this.merchantsignedSve.apiSaveSign(action_body);
break;
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 "merchantTitleInfo":
opResult = await this.merchanttitleSve.apiTitleInfo(action_body);
break;
case "merchantTitleSave":
opResult = await this.merchanttitleSve.apiSaveTitle(action_body);
break;
case "merchantTitleDefault":
opResult = await this.merchanttitleSve.apiSetDefault(action_body);
break;
case "getMerchantTitleDefault":
opResult = await this.merchanttitleSve.apiGetDefault(action_body);
break;
// 商户地址api
case "merchantAddressList":
opResult = await this.merchantaddressSve.apiAddressPage(action_body);
break;
case "merchantAddressInfo":
opResult = await this.merchantaddressSve.apiAddressInfo(action_body);
break;
case "merchantAddressSave":
opResult = await this.merchantaddressSve.apiSaveAddress(action_body);
break;
case "merchantAddressDefault":
opResult = await this.merchantaddressSve.apiSetDefault(action_body);
break;
case "getMerchantAddressDefault":
opResult = await this.merchantaddressSve.apiGetDefault(action_body);
break;
// 资金账户
case "merchantAccountPage":
opResult = await this.merchantaccountSve.apiPage(action_body);
break;
case "merchantAccountInfo":
opResult = await this.merchantaccountSve.apiInfo(action_body);
break;
case "merchantAccountInfoByMerchantId":
opResult = await this.merchantaccountSve.apiInfoByMerchantId(action_body);
break;
// 商户充值api
case "merchantRechargePage":
opResult = await this.merchantrechargeSve.apiPage(action_body);
break;
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;
}
return opResult;
}
exam() {
return `<pre><pre/>`;
}
classDesc() {
return {
groupName: "op",
groupDesc: "元数据服务包",
name: "ActionAPI",
desc: "此类是对外提供接口服务",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: `<pre><pre/>`,
methodName: "springboard",
paramdescs: [
{
paramDesc: "请求的行为,传递如:sjb",
paramName: "action_process",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型,详情见方法中的描述",
paramName: "action_type",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型的参数,action_body必须传递的参数有,times_tamp(时间戳,类型int)、sign(签名,类型string),其余的为业务需要的参数",
paramName: "action_body",
paramType: "json",
defaultValue: null,
}
],
rtnTypeDesc: `<pre><pre/>`,
rtnType: `<pre><pre/>`
}
];
}
}
module.exports = ActionAPI;
\ 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 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
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;
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);
// }
//
// })();
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}]
// }
]
});
}
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}]
// }
]
});
}
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 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 MerchantaddressService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchantaddressService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
async apiAddressPage(params) {
try {
return await this.addressPage(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiAddressInfo(params) {
try {
return await this.addressInfo(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSaveAddress(params) {
try {
return await this.saveAddress(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSetDefault(params) {
try {
return await this.setDefault(params.id);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiGetDefault(params) {
try {
return await this.getDefault(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async saveAddress(params) {
var id = params.id;
var merchantId = params.merchantId;
var address;
if (id) {
address = await this.findById(id);
} else {
address = {
merchant_id: merchantId
};
}
address.mailAddr = this.trim(params.mailAddr);
address.mailTo = this.trim(params.mailTo);
address.mailMobile = this.trim(params.mailMobile);
if (id) {
address = await address.save();
} else {
address = await this.create(address);
}
if (params.isDefault) {
await this.dao.updDefaultByMerchantId(address.merchant_id, false);
await this.dao.updDefaultById(address.id, true);
}
return system.getResultSuccess("");
}
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, "地址不存在");
}
await this.dao.updDefaultByMerchantId(address.merchant_id, false);
await this.dao.updDefaultById(address.id, true);
return system.getResultSuccess();
}
async addressPage(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", "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.setMerchantName(page.rows);
}
return system.getResultSuccess(page);
}
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 {};
}
var ids = [];
for (var row of rows) {
ids.push(row.merchant_id);
}
return await this.merchantDao.findMapByIds(ids, attrs);
}
}
module.exports = MerchantaddressService;
// 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 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 MerchanttitleService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchanttitleService));
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
async apiTitlePage(params) {
try {
return await this.titlePage(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiTitleInfo(params) {
try {
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSaveTitle(params) {
try {
return await this.saveTitle(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSetDefault(params) {
try {
return await this.setDefault(params.id);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiGetDefault(params) {
try {
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 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 saveTitle(params) {
var id = params.id;
var merchantId = params.merchantId;
var title;
if (id) {
title = await this.findById(id);
} else {
title = {
merchant_id: merchantId
};
}
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) {
title = await title.save();
} else {
title = await this.create(title);
}
if (params.isDefault) {
await this.dao.updDefaultByMerchantId(title.merchant_id, false);
await this.dao.updDefaultById(title.id, true);
}
return system.getResultSuccess(title);
}
async setDefault(id) {
var title = await this.dao.findById(id);
if (!title) {
return system.getResult(null, "抬头不存在");
}
await this.dao.updDefaultByMerchantId(title.merchant_id, false);
await this.dao.updDefaultById(title.id, true);
return system.getResultSuccess();
}
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", "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 = MerchanttitleService;
// 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 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);
// });
var excel = require('exceljs');
const system=require("../system");
const uuidv4 = require('uuid/v4');
const fs=require("fs");
class ExcelClient {
constructor() {
this.columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
this.ossClient=system.getObject("util.ossClient");
this.filedownloadDao = system.getObject("db.filedownloadDao");
}
async download(params) {
var self = this;
var title = params.title || "";
var code = params.code || uuidv4();
var fileName = params.fileName || code + ".xlsx";
var filePath = params.filePath || "/tmp/" + fileName;
var rows = params.rows || [];
var user = params.user || {};
var wb = new excel.Workbook();
wb.properties.date1904 = true;
var sheet = wb.addWorksheet("sheet1");
var headers = rows[0];
console.log(headers, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 headers");
if(title) {
sheet.addRow([title]);
sheet.getCell("A1").font = {
    name: '微软雅黑',
    family: 4,
    size: 12,
    bold: true
};
sheet.getCell('A1').alignment = { vertical: 'middle', horizontal: 'center' };
var colkey = 0;
if(headers.length > 0) {
colkey = headers.length - 1;
}
var endColumn = this.columns[colkey] || "A";
sheet.mergeCells("A1:" + endColumn + "1");
}
for(var r of rows) {
sheet.addRow(r);
}
wb.xlsx.writeFile(filePath).then(async function(d) {
var rtn = await self.ossClient.upfile(fileName, filePath);
fs.unlink(filePath,function(err){});
var obj = {
user_id : user.id || 0,
userName : user.userName || "",
code : code,
fileName : fileName,
filePath : rtn.url || "",
isDownload : false,
}
var obj = await self.filedownloadDao.create(obj);
});
}
}
module.exports = ExcelClient;
## 商户服务接口
  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="addressList"> 地址列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantAddressList",
"action_body": {
"currentPage": "1",
"pageSize": "3",
"merchantId": "" // 商户id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 11,
"rows": [
{
"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="addressInfo"> 地址信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantAddressInfo",
"action_body": {
"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是
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {}
}
```
## **<a name="setDefault"> 设置默认</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantAddressDefault",
"action_body": {
"id": "13661984313001961" // 抬头id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
\ No newline at end of file
<a name="menu">目录</a>
1. [充值申请](#add)
1. [充值列表](#list)
1. [充值信息](#info)
1. [充值审核](#audit)
## **<a name="add"> 充值申请</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantRechargeAdd",
"action_body": {
"amt": 100000, // 充值金额(分)
"merchantId": "11064622752480048", // 商户id
"outTradeNo":"杨庆菊2", // 第三方充值流水号
"voucher":"https://www.baidu.com/1.png" // 充值凭证
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"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>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantRechargeAdd",
"action_body": {
"amt": 100000, // 充值金额(分)
"merchantId": "11064622752480048", // 商户id
"outTradeNo":"杨庆菊2", // 第三方充值流水号
"voucher":"https://www.baidu.com/1.png" // 充值凭证
}
}
```
#### 返回结果
```javascript
{
"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": "f8401dfdefcc4809a86d3ae5c70eae12"
}
```
## **<a name="info"> 充值信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantRechargeInfo",
"action_body": {
"id": "1789195248000236"
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"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="audit"> 充值审核</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "sjb",
"action_type": "merchantRechargeAudit",
"action_body": {
"id": "1789198739000692", // 充值id
"status": "20", // 状态 10审核通过 20审核驳回
"remark":"测试接口", // 审核备注
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {},
"requestid": "c359d5fa943a44c99f9f68527c2effb9"
}
```
<a name="menu">目录</a>
1. [商户签约](#merchantSign)
1. [查看签约](#signInfo)
1. [签约列表](#signList)
## **<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
"merchantName": "杨庆菊的公司11编辑" // 商户名称
"nameA": "杨庆菊的主体2222", // 签约主体
"contractNo": "杨庆菊录入合同2222号", // 合同编号
"beginDate": "2019-10-01", // 合同开始时间
"endDate": "2019-10-07", // 合同截至时间
"serviceRate": 322 // 服务费比率(整数防止精度损失)
"created_at": "2019-10-01 11:35", // 创建时间
},
"requestid": "b6df9966b91f4567887a606686952fb0"
}
```
## **<a name="signList"> 签约列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantSignList",
"action_body": {
"currentPage": "1",
"pageSize": "10",
"merchantId": "11064625945481089" // 商户ID
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"merchant_id": "11064625945481089", // 商户id
"merchantName": "杨庆菊的公司11编辑" // 商户名称
"nameA": "杨庆菊的主体2222", // 签约主体
"contractNo": "杨庆菊录入合同2222号", // 合同编号
"beginDate": "2019-10-01", // 合同开始时间
"endDate": "2019-10-07", // 合同截至时间
"serviceRate": 322 // 服务费比率(整数防止精度损失)
"created_at": "2019-10-01 11:35", // 创建时间
}
]
},
"requestid": "83db094399374590b8fd5e09cf39ee9c"
}
```
<a name="menu">目录</a>
1. [抬头列表](#titleList)
1. [抬头信息](#titleInfo)
1. [添加/修改抬头](#saveTitle)
1. [设置默认](#setDefault)
## **<a name="titleList"> 抬头列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantTitleList",
"action_body": {
"currentPage": "1",
"pageSize": "3",
"merchantId": "" // 商户id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 22,
"rows": [
{
"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="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>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantTitleSave",
"action_body": {
"id": "", // 抬头id,为空或者不填写该字段时新增,指定具体id时修改
"merchantId" :"11064624178480175", // 商户id
"taxNo": "杨庆菊客户的税号", // 纳税人识别号
"invoiceAddr": "杨庆菊客户的地址", // 开票地址
"invoiceMobile": "杨庆菊客户开票手机号", // 开票电话
"accountName": "杨庆菊客户的账户名称", // 开户名称
"accountPublic": "杨庆菊客户的对公账户", // 对公账户
"isDefault" : true, // 是否设置默认
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {}
}
```
## **<a name="setDefault"> 设置默认</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "merchantTitleDefault",
"action_body": {
"id": "13661984313001961" // 抬头id
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success"
}
```
\ No newline at end of file
<a name="menu">目录</a>
1. [用户列表](#businessmenList)
1. [合同审核](#contractAudit)
1. [用户签约](#businessmenSign)
## **<a name="businessmenList"> 用户列表 </a>**
[返回到目录](#menu)
##### URL
[/web/order/businessmenCtl/businessmenList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"currentPage": "1",
"pageSize": "10",
"merchantId": "", // 商户ID
"orderNo": "", // 订单号
"status": "", // 用户状态
"name": "", // 个体户名称
"createdBegin": "", // 创建时间-开始
"createdEnd": "" // 创建时间-结束
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 8,
"rows": [
{
"id": 1,
"merchant_id": 110269, // 商户id
"merchantName":"xxxx", // 商户名称
"orderNo": "" // 订单号
"channelOrderNo": "" // 渠道订单号
"status": "" // 00 待处理, 05 执照办理中, 10 已出执照, 15 刻章办理中, 20 已刻章, 25 银行开户中, 30 银行已开户,
// 35 税务报到中, 40 已税务报到, 50 已邮寄, 60 合同待审核, 70 合同审核不通过, 80 合同审核通过, 90 已签约
"legalName": "" // 法人姓名
"legalMobile": "" // 法人电话
"name": "" // 个体工商户名称
"creditCode": "" // 统一社会信用代码
"businessPlace": "" // 经营场所
"businessScope": "" // 经营范围
"regDate": "" // 注册日期
"businessImg": "" // 执照照片
"gongzhang": "" // 公章
"caiwuzhang": "" // 财务章
"fapiaozhang": "" // 发票章
"hetongzhang": "" // 合同章
"farenzhang": "" // 法人章
"isBank": "" // 是否开户
"bankName": "" // 账户名称
"bankNo": "" // 账户号
"bank": "" // 开户行
"bankImg": "" // 账户信息
"caImg": "" // CA照片
"taxRegDay": "" // 税务登记日
"taxOrg": "" // 税务机构名称
"courierNo": "" // 快递单号
"courierImg": "" // 快递交接单图片
"addedValueRate": "" // 增值税率
"supertaxRate": "" // 附加税率
"commonTaxLadder": "" // 普票个税阶梯
"commonOtherLadder": "" // 普票增值税、附加税阶梯
"specialTaxLadder": "" // 专票个税阶梯
"specialOtherLadder": "" // 专票增值税、附加税阶梯
"contract": "" // 个体户合同
"contractStartData": "" // 合同开始时间
"contractEndData": "" // 合同结束时间
"notes": "" // 备注
"opNotes": "" // 操作备注
"created_at": "", // 创建时间
}
]
}
}
```
1. [用户签约](#businessmenSign)
## **<a name="contractAudit"> 合同审核 </a>**
[返回到目录](#menu)
##### URL
[/web/order/businessmenCtl/contractAudit]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": "14", // 个体工商户id
"notes": "xxxxx", // 审核备注,驳回时候必填
"status": "2" // 审核状态 1通过 2驳回
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
## **<a name="businessmenSign"> 用户签约 </a>**
[返回到目录](#menu)
##### URL
[/web/order/businessmenCtl/businessmenSign]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": "1",
"commonTaxLadder": "[{\"minValue\": 0, \"rate\": \"0\", \"maxValue\": 3000000 }]",
"commonOtherLadder": "[{\"minValue\": 0, \"rate\": \"0\", \"maxValue\": 3000000 }]",
"specialTaxLadder": "[{\"minValue\": 0, \"rate\": \"0\", \"maxValue\": 3000000 }]",
"specialOtherLadder": "[{\"minValue\": 0, \"rate\": \"0\", \"maxValue\": 3000000 }]"
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
<a name="menu">目录</a>
1. [订单列表](#orderList)
1. [创建进度](#createStep)
## **<a name="orderList"> 订单列表 </a>**
[返回到目录](#menu)
##### URL
[/web/order/orderCtl/orderList]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"merchant_id": 110361384474, // 商户id
"orderNo": "", // 订单号
"channelOrderNo": "", // 渠道订单号
"createdBegin": "", //
"createdEnd": "",
"status": ""
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 4,
"rows": [
{
"id": 8, // id
"merchant_id": 110361382269, // 商户id
"orderNo": "SJB201909191148sJXGu", // 订单号
"channelOrderNo": "test0003", // 渠道订单号
"legalName": "宋毅修改", // 法人姓名
"legalMobile": "15010929368", // 法人电话
"legalImg": "http://sss1.jpg", // 法人证件照
"idcard": "341221198808328500", // 身份证号码
"idcardFront": "http://sss2.jpg", // 身份证正面照
"idcardBack": "http://sss3.jpg", // 身份证背面照
"bankNo": "33333990209874819", // 银行卡号
"bank": "北京市地球村", // 开户行
"names": "名称1,名称2,名称3", // 名称(英文逗号分割,前端split一下再展示)
"businessScope": "科技服务行业", // 经营范围
"capital": "1000万", // 注册资本
"status": "00", // 订单状态 00待处理 05执照办理中 10已出执照 15刻章办理中
// 20已刻章 25银行开户中 30银行已开户 35税务报到中 40已税务报到 50已邮寄
"statusName": "待处理", // 订单状态名称
"nextStatus": "05", // 订单下一个状态
"nextStatusName": "执照办理中", // 订单下一个状态名称
"notes": null, // 备注
"opNotes": null, // 操作备注
"created_at": "2019-09-19 03:48", // 创建时间
"merchant": {
"id": 110361382269,
"name": "司机宝",
"created_at": "2019-09-10 13:16",
},
"businessmen": {
"orderNo": "" // 订单号
"channelOrderNo": "" // 渠道订单号
"status": "" // 00 待处理, 05 执照办理中, 10 已出执照, 15 刻章办理中, 20 已刻章, 25 银行开户中, 30 银行已开户,
// 35 税务报到中, 40 已税务报到, 50 已邮寄, 60 合同待审核, 70 合同审核不通过, 80 合同审核通过, 90 已签约
"legalName": "" // 法人姓名
"legalMobile": "" // 法人电话
"name": "" // 个体工商户名称
"creditCode": "" // 统一社会信用代码
"businessPlace": "" // 经营场所
"businessScope": "" // 经营范围
"regDate": "" // 注册日期
"businessImg": "" // 执照照片
"gongzhang": "" // 公章
"caiwuzhang": "" // 财务章
"fapiaozhang": "" // 发票章
"hetongzhang": "" // 合同章
"farenzhang": "" // 法人章
"isBank": "" // 是否开户
"bankName": "" // 账户名称
"bankNo": "" // 账户号
"bank": "" // 开户行
"bankImg": "" // 账户信息
"caImg": "" // CA照片
"taxRegDay": "" // 税务登记日
"taxOrg": "" // 税务机构名称
"courierNo": "" // 快递单号
"courierImg": "" // 快递交接单图片
"addedValueRate": "" // 增值税率
"supertaxRate": "" // 附加税率
"commonTaxLadder": "" //普票个税阶梯
"commonOtherLadder": "" //普票增值税、附加税阶梯
"specialTaxLadder": "" //专票个税阶梯
"specialOtherLadder": "" //专票增值税、附加税阶梯
"contract": "" //个体户合同
"contractStartData": "" //合同开始时间
"contractEndData": "" //合同结束时间
"notes": "" //备注
"opNotes": "" //操作备注
}
},
]
}
}
```
## **<a name="createStep"> 创建进度 </a>**
[返回到目录](#menu)
##### URL
[/web/order/orderCtl/createStep]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
// 公共变量,所有情况都需要传
"orderId": "1", // 订单id
"status": "10", // 订单状态
// 出执照
"name": "杨庆菊有限公司", // 个体工商户名称
"creditCode": "xxxxxx333333333", // 社会统一信用代码
"businessPlace": "来广营地铁站", // 经营场所
"businessScope": "1,2,3,4,5,", // 经营范围
"regDate": "2019-01-22", // 注册时间
"businessImg": "http:1.png" // 执照照片
// 刻章办理
"gongzhang": "http://gongzhang.png", // 公章
"caiwuzhang": "http://caiwuzhang.png", // 财务章
"fapiaozhang": "http://fapiaozhang.png", // 发票章
"hetongzhang": "http://hetongzhang.png", // 合同章
"farenzhang": "http://farenzhang.png" // 法人章
// 银行开户
"isBank":"1", // 是否开户 0否 1是
"bankName":"https://bankName", // 账户名称
"bankNo":"https://bankNo", // 账户号
"bank":"https://bank", // 开户行
"bankImg":"https://bankImg", // 账户信息
// 税务报到
"caImg": "12313212", // CA认证图
"taxRegDay": "2019-01-01", // 税务登记日
"taxOrg": "12333" // 税务机构名称
// 已邮寄
"courierNo": "111111111" // 快递单号
"courierImg": "快递交接图片" // courierImg`
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
<a name="menu">目录</a>
1. [图片验证码](#captcha)
1. [短信验证码](#smsCode)
1. [登录](#login)
1. [当前用户信息查询](#loginUser)
1. [获取菜单](#getMenu)
## **<a name="captcha"> 图片验证码</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/captcha]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明|
| -------- | -------- | ------------|---------|
| **width** | 否 | int | 图片验证码宽度 默认120px|
| **height** | 否 | int | 图片验证码高度 默认32px |
| **background** | 否 | String | 背景色颜色值,默认#E8E8E8 |
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"key": "381c1fc567c746d0a4aa33892239cef0", // 图片验证码key
"captcha": "...." // 图片
}
}
```
## **<a name="smsCode"> 短信验证码</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/smsCode]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明|
| -------- | -------- | ------------|---------|
| **mobile** | 是 | String | 手机号码|
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
## **<a name="login"> 登录</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/login]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明|
| -------- | -------- | ------------|---------|
| **loginName** | 是 | String | 登录名|
| **password** | 是 | String | 密码 |
| **captchaKey** | 是 | String | 图片验证码key |
| **captchaCode** | 是 | String | 图片验证码填入值 |
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"xggadminsid": "3cb49932-fa02-44f0-90db-9f06fe02e5c7" // 登录key
}
}
```
## **<a name="currentUser"> 当前用户信息查询</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/currentUser]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
## **<a name="getMenu"> 获取菜单</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/getMenu]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 返回结果
```javascript
[
{
"name": "首页",
"path": "/",
"submenu": []
},
{
"name": "商户中心",
"path": "/merchants",
"submenu": [
{
"name": "客户管理",
"team": [
{
"name": "商户信息",
"path": "/merchants/businessInformation"
},
...
]
}
]
},
...
]
```
......@@ -65,39 +65,7 @@ class APIBase extends DocBase {
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var appInfo = null;
var result = system.getResultSuccess();
var ispass = await this.isCheckWhiteList(gname, methodname);
var appkey = req.headers["accesskey"];
var app_id = req.headers["app_id"];
if (ispass) {
return result;
}
//在白名单里面
// 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;
return system.getResultSuccess();
}
async doexec(gname, methodname, pobj, query, req) {
var requestid = this.getUUID();
......
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
this.iborderSve = system.getObject("service.order.iborderSve");
this.iborderdeliverSve = system.getObject("service.order.iborderdeliverSve");
this.businessmenSve = system.getObject("service.business.businessmenSve");
this.businessmencontractSve = system.getObject("service.business.businessmencontractSve");
}
/**
* 接口跳转
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springboard(pobj, qobj, req) {
var result;
if (!pobj.action_process) {
return system.getResult(null, "action_process参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "action_type参数不能为空");
}
console.log(pobj.action_process, pobj.action_type, pobj.action_body, "---------------- this is order micro sve --------------------");
try {
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
} catch (error) {
console.log(error);
}
return result;
}
async handleRequest(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// 订单
case "addOrder":
opResult = await this.iborderSve.apiAdd(action_body);
break;
case "updOrder":
opResult = await this.iborderSve.apiUpd(action_body);
break;
case "allOrderList":
opResult = await this.iborderSve.apiAllList(action_body);
break;
case "orderInfo":
opResult = await this.iborderSve.apiInfo(action_body);
break;
case "orderInfoAll":
opResult = await this.iborderSve.apiAllInfo(action_body);
break;
case "byChannelOrderId":
opResult = await this.iborderSve.apiByChannelOrderId(action_body);
break;
case "orderEdit":
opResult = await this.iborderSve.apiEdit(action_body);
break;
case "orderAssign":
opResult = await this.iborderSve.apiAssign(action_body);
break;
case "myOrderPage":
opResult = await this.iborderSve.apiMyPage(action_body);
break;
case "orderPay":
opResult = await this.iborderSve.apiOrderPay(action_body);
break;
case "orderClose":
opResult = await this.iborderSve.apiOrderClose(action_body);
break;
case "closeOrderById":
opResult = await this.iborderSve.apiCloseById(action_body);
break;
case "orderComplete":
opResult = await this.iborderSve.apiComplete(action_body);
break;
case "orderByDeliverId":
opResult = await this.iborderSve.apiByDeliverId(action_body);
break;
// 订单办理
case "orderDeliverList":
opResult = await this.iborderdeliverSve.apiPage(action_body);
break;
case "orderDeliverHandle":
opResult = await this.iborderdeliverSve.apiHandle(action_body);
break;
case "orderDeliverInfo":
opResult = await this.iborderdeliverSve.apiInfo(action_body);
break;
case "orderDeliverEdit":
opResult = await this.iborderdeliverSve.apiEdit(action_body);
break;
case "orderDeliverAudit":
opResult = await this.iborderdeliverSve.apiAudit(action_body);
break;
case "orderDeliverClose":
opResult = await this.iborderdeliverSve.apiClose(action_body);
break;
// 个体户管理
case "businessmenByOrderId":
opResult = await this.businessmenSve.apiByOrderId(action_body);
break;
case "businessmenByChannelOrderNo":
opResult = await this.businessmenSve.apiByChannelOrderNo(action_body);
break;
case "businessmenNameList":
opResult = await this.businessmenSve.apiNameList(action_body);
break;
case "businessmenPage":
opResult = await this.businessmenSve.apiPage(action_body);
break;
case "businessmenInfo":
opResult = await this.businessmenSve.apiInfo(action_body);
break;
case "businessmenSign":
opResult = await this.businessmenSve.apiSign(action_body);
break;
case "businessmenSignPage":
opResult = await this.businessmenSve.apiSignPage(action_body);
break;
case "businessmenInfoPage":
opResult = await this.businessmenSve.apiInfoPage(action_body);
break;
case "businessmenUserPage":
opResult = await this.businessmenSve.apiUserPage(action_body);
break;
case "businessmenDeliverPage":
opResult = await this.businessmenSve.apiDeliverPage(action_body);
break;
case "addBusinessmenContract":
opResult = await this.businessmenSve.apiAddContract(action_body);
break;
case "businessmenCompleteMapByCreditCodes":
opResult = await this.businessmenSve.apiCompleteMapByCreditCodes(action_body);
break;
// 统计数据
case "statTransData":
opResult = await this.iborderSve.apiStatTransData(action_body);
break;
case "statBusinessData":
opResult = await this.iborderSve.apiStatBusinessData(action_body);
break;
case "statDeliverData":
opResult = await this.iborderdeliverSve.apiStatDeliverData(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
exam() {
return `<pre><pre/>`;
}
classDesc() {
return {
groupName: "op",
groupDesc: "元数据服务包",
name: "ActionAPI",
desc: "此类是对外提供接口服务",
exam: "",
};
}
methodDescs() {
return [{
methodDesc: `<pre><pre/>`,
methodName: "springboard",
paramdescs: [{
paramDesc: "请求的行为,传递如:sjb",
paramName: "action_process",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型,详情见方法中的描述",
paramName: "action_type",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型的参数,action_body必须传递的参数有,times_tamp(时间戳,类型int)、sign(签名,类型string),其余的为业务需要的参数",
paramName: "action_body",
paramType: "json",
defaultValue: null,
}
],
rtnTypeDesc: `<pre><pre/>`,
rtnType: `<pre><pre/>`
}];
}
}
module.exports = ActionAPI;
\ No newline at end of file
......@@ -4,7 +4,6 @@ const settings = require("../../../config/settings");
class ApiAppIdCheckCache extends CacheBase {
constructor() {
super();
this.merchantDao = system.getObject("db.merchant.merchantDao");
}
desc() {
return "应用中来访访问appid缓存";
......
......@@ -3,6 +3,8 @@ class Dao {
constructor(modelName) {
this.modelName = modelName;
this.redisClient = system.getObject("util.redisClient");
this.orderBusinessStatus = system.getObject("util.orderBusinessStatus");
var db = system.getObject("db.common.connection").getCon();
this.db = db;
console.log("........set dao model..........");
......@@ -31,6 +33,20 @@ class Dao {
});
}
}
//批量插入
async bulkCreate(objs) {
if (!objs || objs.length == 0) {
return;
}
for (var obj of objs) {
if (!obj.id) {
obj.id = await this.redisClient.genrateId(this.modelName);
}
}
return await this.model.bulkCreate(objs);
}
static getModelName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase()
}
......@@ -65,6 +81,7 @@ class Dao {
where: qobj
});
if (en != null) {
1
return en.destroy();
}
return null;
......@@ -297,6 +314,18 @@ class Dao {
item[field + "Name"] = map[item[field] || ""] || "";
}
async getRowCodeName(item, field) {
if (!item || !field) {
return "";
}
var map = this[field + "Map"] || {};
if (!item) {
return "";
}
return map[item[field] || ""] || "";
}
async getById(id, attrs) {
if (!id) {
return null;
......@@ -321,5 +350,18 @@ class Dao {
ids: ids
}) || [];
}
async getMapByIds(ids, attrs) {
var result = {};
var list = await this.getListByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = Dao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class BusinessmenDao extends Dao {
constructor() {
super(Dao.getModelName(BusinessmenDao));
this.bstatusMap = {
"2000": "办理中",
"2010": "待签约",
"2020": "已完成",
}
this.gstatusMap = {
"2000": "办理中",
"2020": "已完成",
}
this.dstatusMap = {
"2000": "办理中",
"2020": "已完成",
}
}
async nameList(bstatuses) {
var sql = "SELECT id, name FROM " + this.model.tableName + " WHERE 1 = 1 ";
var params = {};
if (bstatuses && bstatuses.length > 0) {
sql = sql + " AND bstatus IN (:bstatuses) ";
params.bstatuses = bstatuses;
}
return this.customQuery(sql, params);
}
async getByOrderId(orderId, attrs) {
if (!orderId) {
return null;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where order_id = :orderId ";
var list = await this.customQuery(sql, {
orderId: orderId
});
return list && list.length > 0 ? list[0] : null;
}
async getByChannelOrderNo(merchantId, channelOrderNo, attrs) {
if (!merchantId || !channelOrderNo) {
return null;
}
var params = {
merchantId: merchantId,
channelOrderNo: channelOrderNo,
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where merchant_id = :merchantId AND channelOrderNo = :channelOrderNo LIMIT 1";
var list = await this.customQuery(sql, params);
return list && list.length > 0 ? list[0] : null;
}
async getByCreditCodes(params, attrs) {
var creditCodes = params.creditCodes;
var statuses = params.statuses;
var result = {};
if (!creditCodes || creditCodes.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where creditCode IN (:creditCodes) ";
if (statuses && statuses.length > 0) {
sql = sql + " AND bstatus IN (:statuses) "
}
return await this.customQuery(sql, params);
}
async getMapByCreditCodes(params, attrs) {
var result = {};
var list = this.getByCreditCodes(params, attrs);
if (!list) {
return result;
}
for (var item of list) {
result[item.creditCode] = item;
}
return result;
}
}
module.exports = BusinessmenDao;
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class BusinessmencontractDao extends Dao{
constructor(){
super(Dao.getModelName(BusinessmencontractDao));
}
}
module.exports=BusinessmencontractDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class BusinessmeninvoicecontentDao extends Dao{
constructor(){
super(Dao.getModelName(BusinessmeninvoicecontentDao));
}
async delByBusinessmenId(businessmenId, t) {
var sql = "DELETE FROM " + this.model.tableName + " WHERE businessmen_id = :businessmenId";
var list = await this.customUpdate(sql, {
businessmenId: businessmenId
}, t) || [null];
return list[0];
}
async mapByBusinessmenIds(businessmenIds, attrs) {
var result = {};
if (!businessmenIds || businessmenIds.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "SELECT businessmen_id, invoicecontent_id, invoicecontentName FROM " + this.model.tableName + " where businessmen_id IN (:businessmenIds) ";
var list = await this.customQuery(sql, {
businessmenIds: businessmenIds
});
if(!list) {
return result;
}
for(var item of list) {
var lst = result[item.businessmen_id];
if(!lst) {
lst = [];
}
lst.push(item);
result[item.businessmen_id] = lst;
}
return result;
}
}
module.exports=BusinessmeninvoicecontentDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class IborderDao extends Dao {
constructor() {
super(Dao.getModelName(IborderDao));
this.statusMap = {
"1000": "未付款",
"1010": "订单关闭",
"1020": "待分配",
"1030": "待处理",
"1040": "交付商关闭",
"1050": "执照办理中",
"1060": "已出执照",
"1070": "刻章办理中",
"1080": "已刻章",
"1090": "银行开户中",
"1100": "银行卡已开户",
"1110": "税务报道中",
"1120": "已税务报道",
"1130": "待审核",
"1140": "审核失败",
"1150": "审核通过",
"1160": "已邮寄",
"1170": "已完成",
};
this.ostatusMap = {
"1000": "未付款",
"1010": "订单关闭",
"1030": "待处理",
"1050": "执照办理中",
"1060": "已出执照",
"1070": "刻章办理中",
"1080": "已刻章",
"1090": "银行开户中",
"1100": "银行卡已开户",
"1110": "税务报道中",
"1120": "已税务报道",
"1170": "已完成",
};
this.deliverTypeMap = {
"10": "交付商交付",
"20": "平台交付",
"30": "平台保存无需交付",
}
}
async statOrderByTime(begin, end) {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(1) AS orderCount, SUM(price) AS orderPrice");
sql.push("FROM `ib_order`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return {
orderCount: 0,
orderPrice: 0,
}
}
var item = list[0];
return {
orderCount: item.orderCount || 0,
orderPrice: item.orderPrice || 0,
}
}
async statDayByTime(begin, end) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(created_at, '%Y-%m-%d') AS `day`, SUM(price) AS orderPrice, COUNT(1) AS orderCount");
sql.push("FROM `ib_order`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
sql.push("GROUP BY `day` ORDER BY `day` ASC");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.day] = item;
}
return result;
}
async statMonthByTime(begin, end) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(created_at, '%Y-%m') AS `month`, SUM(price) AS orderPrice, COUNT(1) AS orderCount");
sql.push("FROM `ib_order`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
sql.push("GROUP BY `month` ORDER BY `month` ASC");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var idx = 0; idx < list.length; idx++) {
var item = list[idx];
result[item.month] = item;
if (idx == 0) {
result.begin = item.month;
}
if (idx == list.length - 1) {
result.end = item.month;
}
}
return result;
}
async statByStatus(begin, end) {
var sql = [];
sql.push("SELECT");
sql.push("`status`, COUNT(1) AS orderCount ");
sql.push("FROM `ib_order`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
sql.push("GROUP BY `status`");
var result = {};
var list = await this.customQuery(sql.join(" "), params);
if(!list || list.length == 0) {
return result;
}
for(var item of list) {
result[item.status] = item.orderCount || 0;
}
return result;
}
}
module.exports = IborderDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IborderdeliverDao extends Dao {
constructor() {
super(Dao.getModelName(IborderdeliverDao));
this.statusMap = {
"1030": "待处理",
"1040": "关闭订单",
"1050": "执照办理中",
"1060": "已出执照",
"1070": "刻章办理中",
"1080": "已刻章",
"1090": "银行开户中",
"1100": "银行卡已开户",
"1110": "税务报道中",
"1120": "已税务报道",
"1130": "待审核",
"1140": "审核失败",
"1150": "审核通过",
"1160": "已邮寄",
};
}
async findAssignedOrder(orderId) {
var sql = "SELECT * FROM `ib_order_deliver` WHERE order_id = :orderId AND `status` <> '1040' LIMIT 1";
var list = await this.customQuery(sql, {
orderId: orderId
});
return list && list.length > 0 ? list[0] : null;
}
async findMapByOrderIds(orderIds) {
var result = {};
var sql = "SELECT * FROM `ib_order_deliver` WHERE order_id IN (:orderIds) AND `status` <> '1040' LIMIT 1";
var list = await this.customQuery(sql, {
orderIds: orderIds
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
await this.setRowCodeName(item, "status");
result[item.order_id] = item;
}
return result;
}
async findMapByOrderIds(orderIds) {
var result = {};
var sql = "SELECT * FROM `ib_order_deliver` WHERE order_id IN (:orderIds) AND `status` <> '9000'";
var list = await this.customQuery(sql, {
orderIds: orderIds
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
await this.setRowCodeName(item, "status");
result[item.order_id] = item;
}
return result;
}
async findMapByIds(ids) {
var result = {};
var sql = "SELECT * FROM `ib_order_deliver` WHERE id IN (:ids)";
var list = await this.customQuery(sql, {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
await this.setRowCodeName(item, "status");
result[item.id] = item;
}
return result;
}
async countStat(params) {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(DISTINCT deliver_id) AS total");
sql.push("FROM `ib_order_deliver`");
sql.push("WHERE 1 = 1");
this.setCondition(params, sql);
var list = await this.customQuery(sql.join(" "), params);
return list && list.length > 0 ? (list[0].total || 0) : 0;
}
async queryStat(params, startRow, pageSize) {
var sql = [];
// SELECT deliver_id, deliverName, SUM(deliverDivide) AS servicePrice FROM `ib_order_deliver` GROUP BY deliver_id;
sql.push("SELECT");
sql.push("deliver_id, deliverName, SUM(deliverDivide) AS servicePrice");
sql.push("FROM `ib_order_deliver` ");
sql.push("WHERE 1 = 1");
this.setCondition(params, sql);
sql.push("GROUP BY deliver_id");
sql.push("LIMIT :startRow, :pageSize");
params.startRow = startRow;
params.pageSize = pageSize;
var list = await this.customQuery(sql.join(" "), params);
return list;
}
async statDeliverByStatus(params) {
var sql = [];
sql.push("SELECT");
sql.push("deliver_id, `status`, COUNT(1) AS orderCount");
sql.push("FROM `ib_order_deliver`");
sql.push("WHERE 1 = 1");
if(params.deliverIds) {
sql.push("AND deliver_id IN (:deliverIds)")
}
if (params.begin) {
sql.push("AND created_at >= :begin");
}
if (params.end) {
sql.push("AND created_at <= :end");
}
sql.push("GROUP BY `status`");
var result = {};
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.deliver_id + "_" + item.status] = item.orderCount || 0;
}
return result;
}
setCondition(params, sql) {
if (params.begin) {
sql.push("AND created_at >= :begin");
}
if (params.end) {
sql.push("AND created_at <= :end");
}
}
}
module.exports = IborderdeliverDao;
\ 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("merchant", {
return db.define("businessmen", {
order_id: DataTypes.STRING(32),
merchant_id: DataTypes.STRING(32),
channelOrderNo: DataTypes.STRING(64),
// 业务状态: 2000办理中, 2010待签约, 2020已完成
bstatus: DataTypes.STRING(10),
// 客户状态: 2000办理中, 2020已完成
gstatus: DataTypes.STRING(10),
// 客户状态: 2000办理中, 2020已完成
dstatus: DataTypes.STRING(10),
legalName: DataTypes.STRING(20),
legalMobile: DataTypes.STRING(20),
legalIdcard: DataTypes.STRING(30),
name: DataTypes.STRING(100),
taxType: DataTypes.STRING(4),
contactName: DataTypes.STRING(30),
contactMobile: DataTypes.STRING(30),
contactEmail: DataTypes.STRING(30),
invoiceValid: {
creditCode: DataTypes.STRING(100),
businessPlace: DataTypes.STRING(100),
businessScope: DataTypes.STRING(500),
regDate: DataTypes.DATE,
businessImg: DataTypes.STRING(300),
gongzhang: DataTypes.STRING(300),
caiwuzhang: DataTypes.STRING(300),
fapiaozhang: DataTypes.STRING(300),
hetongzhang: DataTypes.STRING(300),
farenzhang: DataTypes.STRING(300),
isBank: {
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),//商户密钥信息,用于进行签名请求接口
bankName: DataTypes.STRING(50),
bankNo: DataTypes.STRING(30),
bank: DataTypes.STRING(100),
bankImg: DataTypes.STRING(300),
caImg: DataTypes.STRING(300),
taxRegDay: DataTypes.DATE,
taxOrg: DataTypes.STRING(100),
courierNo: DataTypes.STRING(100),
courierImg: DataTypes.STRING(100),
contractStartData: DataTypes.DATE,
contractEndData: DataTypes.DATE,
contract: DataTypes.STRING(300), //个体户合同
notes: DataTypes.STRING, //备注
opNotes: DataTypes.STRING, //操作备注
// 个体户签约相关字段
taxUpType: DataTypes.STRING,
addValueUpType: DataTypes.STRING,
costRate: DataTypes.INTEGER,
taxRate: DataTypes.INTEGER,
serviceRate: DataTypes.INTEGER,
signNotes: DataTypes.STRING,
commonTaxLadder: DataTypes.STRING(1000),
commonOtherLadder: DataTypes.STRING(1000),
specialTaxLadder: DataTypes.STRING(1000),
specialOtherLadder: DataTypes.STRING(1000),
signTime: DataTypes.DATE,
bdId: DataTypes.STRING,
bdPath: DataTypes.STRING,
userId: DataTypes.STRING,
}, {
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}]
// }
]
});
}
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ib_businessmen',
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
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchantaddress", {
return db.define("businessmencontract", {
businessmen_id: DataTypes.STRING(32),
merchant_id: DataTypes.STRING(32),
mailAddr: DataTypes.STRING(200),
mailTo: DataTypes.STRING(200),
mailMobile: DataTypes.STRING(200),
isDefault: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
contractStartData: DataTypes.DATE,
contractEndData: DataTypes.DATE,
contract: DataTypes.STRING(300),//个体户合同
}, {
paranoid: true,//假的删除
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_address',
validate: {
},
tableName: 'ib_businessmen_contract',
validate: {},
indexes: [
// Create a unique index on email
// {
......@@ -53,4 +48,4 @@ module.exports = (db, DataTypes) => {
// }
]
});
}
}
\ 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("merchantpushlog", {
merchant_id: DataTypes.STRING,
api: DataTypes.STRING(200),
params: DataTypes.STRING(5000),
rs: DataTypes.STRING(200),
success: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
return db.define("businessmeninvoicecontent", {
businessmen_id: DataTypes.STRING(32),
invoicecontent_id: DataTypes.STRING(32),
invoicecontentName: DataTypes.STRING(32),
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_push_log',
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}]
// }
]
});
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ib_businessmen_invoicecontent',
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,58 +2,98 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("merchanttitle", {
return db.define("iborder", {
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,
defaultValue: false
},
channelOrderNo: DataTypes.STRING(64),
price: DataTypes.BIGINT,
legalName: DataTypes.STRING(20),
legalMobile: DataTypes.STRING(20),
legalImg: DataTypes.STRING(300),
idcard: DataTypes.STRING(20),
idcardFront: DataTypes.STRING(300),
idcardBack: DataTypes.STRING(300),
bankNo: DataTypes.STRING(30),
bank: DataTypes.STRING(200),
bankImg: DataTypes.STRING(300),
names: DataTypes.STRING(300),
domicile_id: DataTypes.STRING(32),
domicileName: DataTypes.STRING(20),
businessScope_id: DataTypes.STRING(32),
businessType: DataTypes.STRING(100),
businessScope: DataTypes.STRING(500),
capital: DataTypes.STRING(100),
// 平台状态 1000未付款, 1010待处理, 1020执照办理中, 1030已出执照, 1040刻章办理中, 1050已刻章,
// 1060银行开户中, 1070银行已开户, 1080税务报道中, 1090已税务报道, 1100已完成
status: DataTypes.STRING(10),
// 订单状态:1000未付款, 1010订单关闭, 1030待处理, 1050执照办理中, 1060已出执照, 1070刻章办理中,
// 1080已刻章, 1090银行开户中, 1100银行卡已开户, 1110税务报道中, 1120已税务报道, 1170已完成
ostatus: DataTypes.STRING(10),
notes: DataTypes.STRING, // 备注
opNotes: DataTypes.STRING, // 操作备注
bdId: DataTypes.STRING,
bdPath: DataTypes.STRING,
userId: DataTypes.STRING,
mailAddr: DataTypes.STRING,
mailTo: DataTypes.STRING,
mailMobile: DataTypes.STRING,
assignTime: DataTypes.DATE,
assignUcname: DataTypes.STRING,
orderDeliverId: DataTypes.STRING,
deliverType: DataTypes.STRING,
deliverNo: DataTypes.STRING,
deliverImg: DataTypes.STRING,
}, {
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}]
// }
]
});
}
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ib_order',
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,20 +2,26 @@ 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),
return db.define("iborderdeliver", {
order_id: DataTypes.STRING(32),
// 办理状态 1030待处理, 1040关闭订单, 1050执照办理中, 1060已出执照, 1070刻章办理中,
// 1080已刻章, 1090银行开户中, 1100银行卡已开户, 1110税务报道中, 1120已税务报道,
// 1130提交审核, 1140审核失败, 1150审核通过, 1160已邮寄
status: DataTypes.STRING(10),
deliver_id: DataTypes.STRING(32),
deliverName: DataTypes.STRING(50),
deliverDivide: DataTypes.BIGINT,
auditRemark: DataTypes.STRING,
content: DataTypes.STRING,
addressee: DataTypes.STRING,
mobile: DataTypes.STRING,
addr: DataTypes.STRING,
auditUser: DataTypes.STRING,
auditResult: DataTypes.STRING,
breakReason: DataTypes.STRING(300),
}, {
paranoid: true, //假的删除
underscored: true,
......@@ -23,7 +29,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'm_merchant_push',
tableName: 'ib_order_deliver',
validate: {},
indexes: [
// Create a unique index on email
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class BusinessmencontractService extends ServiceBase {
constructor() {
super("business", ServiceBase.getDaoName(BusinessmencontractService));
}
async api(params) {
try {
return await this.xxx(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiAdd(params) {
try {
return await this.apiSave(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async add(params) {
return system.getResultSuccess();
}
async method(params) {
return system.getResultSuccess();
}
}
module.exports = BusinessmencontractService;
// 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 fs=require("fs");
var excel = require('exceljs');
const uuidv4 = require('uuid/v4');
var path= require('path');
class TaskService extends ServiceBase{
......
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