Commit 905573b2 by 孙亚楠

dd

parent bc71906e
...@@ -6,7 +6,7 @@ class BmorderService extends ServiceBase { ...@@ -6,7 +6,7 @@ class BmorderService extends ServiceBase {
//this.appDao=system.getObject("db.appDao"); //this.appDao=system.getObject("db.appDao");
this.bmuserbizDao = system.getObject("db.bmuserbizDao"); this.bmuserbizDao = system.getObject("db.bmuserbizDao");
this.statusMap = { this.statusMap = {
0:"待审核", 1:"审核通过", 2:"审核驳回", 0: "待审核", 1: "审核通过", 2: "审核驳回",
}; };
} }
...@@ -119,52 +119,54 @@ class BmorderService extends ServiceBase { ...@@ -119,52 +119,54 @@ class BmorderService extends ServiceBase {
let self = this; let self = this;
let res = await this.db.transaction(async function (t) { let res = await this.db.transaction(async function (t) {
// 创建订单 // 创建订单
await self.dao.model.update(order,{where:{id:order.id}},t); await self.dao.model.update(order, { where: { id: order.id } }, t);
// 创建用户材料 // 创建用户材料
await self.bmuserbizDao.model.update(userbiz,{where:{ await self.bmuserbizDao.model.update(userbiz, {
orderId:order.id where: {
}} ,t); orderId: order.id
}
}, t);
}); });
return { return {
code: 1, code: 1,
msg: "success", msg: "success",
data:res data: res
}; };
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,error); return system.getResult(null, error);
} }
} }
/** /**
* 查询明细 * 查询明细
* @param {*} params * @param {*} params
*/ */
async queryOrderInfo(params){ async queryOrderInfo(params) {
if(!params.id){ if (!params.id) {
return system.getResult(null,`参数错误 订单ID 不能为空`); return system.getResult(null, `参数错误 订单ID 不能为空`);
} }
try { try {
let order = await this.findById(params.id); let order = await this.findById(params.id);
if(!order) { if (!order) {
return system.getResult(null,`订单不存在`); return system.getResult(null, `订单不存在`);
} }
order.dataValues.auditStatusName = this.statusMap[order.auditStatus]; order.dataValues.auditStatusName = this.statusMap[order.auditStatus];
order.dataValues.statusName = order.dataValues.auditStatusName; order.dataValues.statusName = order.dataValues.auditStatusName;
let child = await this.bmuserbizDao.findOne({orderId: params.id}); let child = await this.bmuserbizDao.findOne({ orderId: params.id });
order.dataValues.child = child || {}; order.dataValues.child = child || {};
return { return {
code: 1, code: 1,
msg: "success", msg: "success",
orderInfo:order orderInfo: order
}; };
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,error); return system.getResult(null, error);
} }
} }
async setBizs(list) { async setBizs(list) {
if (!list || list.length == 0) { if (!list || list.length == 0) {
......
...@@ -19,8 +19,8 @@ class ChuangfuApplet extends AppletBase { ...@@ -19,8 +19,8 @@ class ChuangfuApplet extends AppletBase {
this.bmorderSve = system.getObject("service.bmorderSve"); this.bmorderSve = system.getObject("service.bmorderSve");
this.bmmerchantbusinessscopeSve = system.getObject("service.bmmerchantbusinessscopeSve"); this.bmmerchantbusinessscopeSve = system.getObject("service.bmmerchantbusinessscopeSve");
this.dictUtils = system.getObject("util.dictUtils"); this.dictUtils = system.getObject("util.dictUtils");
this.uploadCtl=system.getObject("web.uploadCtl"); this.uploadCtl = system.getObject("web.uploadCtl");
this.idcardClient = system.getObject("util.idcardClient"); this.idcardClient = system.getObject("util.idcardClient");
this.merchantId = 3; this.merchantId = 3;
} }
...@@ -28,7 +28,7 @@ class ChuangfuApplet extends AppletBase { ...@@ -28,7 +28,7 @@ class ChuangfuApplet extends AppletBase {
// 设置登录缓存 // 设置登录缓存
async setLoginUser(id) { async setLoginUser(id) {
var user = await this.bmuserSve.findById(id); var user = await this.bmuserSve.findById(id);
await this.cacheManager["BMUserCache"].set(this.merchantId+"_"+user.openId, JSON.stringify(user)); await this.cacheManager["BMUserCache"].set(this.merchantId + "_" + user.openId, JSON.stringify(user));
return user; return user;
} }
...@@ -44,7 +44,7 @@ class ChuangfuApplet extends AppletBase { ...@@ -44,7 +44,7 @@ class ChuangfuApplet extends AppletBase {
var decryptObj = { var decryptObj = {
encryptedData: encryptedData, encryptedData: encryptedData,
iv: iv, iv: iv,
sessionKey: wxSession.session_key sessionKey: wxSession.session_key
}; };
console.log(decryptObj); console.log(decryptObj);
var decryptData = await this.decryptData(decryptObj); var decryptData = await this.decryptData(decryptObj);
...@@ -54,11 +54,11 @@ class ChuangfuApplet extends AppletBase { ...@@ -54,11 +54,11 @@ class ChuangfuApplet extends AppletBase {
// TODO 找文档,看失效时间 // TODO 找文档,看失效时间
this.redisClient.set("session_key_" + decryptData.openId, wxSession.session_key); this.redisClient.set("session_key_" + decryptData.openId, wxSession.session_key);
console.log("wx ------------------------------------ login"); console.log("wx ------------------------------------ login");
user = await this.bmuserSve.findOne({openId: decryptData.openId,merchantId:this.merchantId}); user = await this.bmuserSve.findOne({ openId: decryptData.openId, merchantId: this.merchantId });
if (!user) { if (!user) {
user = { user = {
openId: decryptData.openId, openId: decryptData.openId,
merchantId:this.merchantId, merchantId: this.merchantId,
mobile: "", mobile: "",
passwd: "", passwd: "",
nickname: decryptData.nickName, nickname: decryptData.nickName,
...@@ -70,7 +70,7 @@ class ChuangfuApplet extends AppletBase { ...@@ -70,7 +70,7 @@ class ChuangfuApplet extends AppletBase {
//创建用户信息 //创建用户信息
user = await this.bmuserSve.create(user); user = await this.bmuserSve.create(user);
} }
this.cacheManager["BMUserCache"].set(this.merchantId+"_"+decryptData.openId, JSON.stringify(user)); this.cacheManager["BMUserCache"].set(this.merchantId + "_" + decryptData.openId, JSON.stringify(user));
} }
return { return {
code: 1, code: 1,
...@@ -91,18 +91,18 @@ class ChuangfuApplet extends AppletBase { ...@@ -91,18 +91,18 @@ class ChuangfuApplet extends AppletBase {
code: -200, code: -200,
msg: "error", msg: "error",
data: {}, data: {},
stack : e.stack stack: e.stack
}; };
} }
} }
async loginUser(gobj, pobj, req, loginUser) { async loginUser(gobj, pobj, req, loginUser) {
return {code : 1, data: loginUser}; return { code: 1, data: loginUser };
} }
async commonInfo(gobj, pobj, req, loginUser) { async commonInfo(gobj, pobj, req, loginUser) {
return { return {
code : 1, code: 1,
data: { data: {
telphone: "15210210265" telphone: "15210210265"
} }
...@@ -113,7 +113,7 @@ class ChuangfuApplet extends AppletBase { ...@@ -113,7 +113,7 @@ class ChuangfuApplet extends AppletBase {
async merchantInfo(gobj, pobj, req, loginUser) { async merchantInfo(gobj, pobj, req, loginUser) {
try { try {
var info = await this.bmmerchantSve.getMerchantInfo(pobj.id); var info = await this.bmmerchantSve.getMerchantInfo(pobj.id);
var result = {code : 1, data: info}; var result = { code: 1, data: info };
return result; return result;
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e.stack);
...@@ -128,7 +128,7 @@ class ChuangfuApplet extends AppletBase { ...@@ -128,7 +128,7 @@ class ChuangfuApplet extends AppletBase {
code: -200, code: -200,
msg: "error", msg: "error",
data: {}, data: {},
stack : e.stack stack: e.stack
}; };
} }
} }
...@@ -137,12 +137,12 @@ class ChuangfuApplet extends AppletBase { ...@@ -137,12 +137,12 @@ class ChuangfuApplet extends AppletBase {
async saveOrder(gobj, pobj, req, loginUser) { async saveOrder(gobj, pobj, req, loginUser) {
try { try {
var rs = await this.buildOrder(pobj, loginUser); var rs = await this.buildOrder(pobj, loginUser);
if(rs.code === 0) { if (rs.code === 0) {
return rs; return rs;
} }
var info = await this.bmorderSve.saveOrderBiz(rs.data); var info = await this.bmorderSve.saveOrderBiz(rs.data);
var result = {code : 1}; var result = { code: 1 };
return result; return result;
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e.stack);
...@@ -153,82 +153,83 @@ class ChuangfuApplet extends AppletBase { ...@@ -153,82 +153,83 @@ class ChuangfuApplet extends AppletBase {
content: e.stack, content: e.stack,
clientIp: req.clientIp clientIp: req.clientIp
}); });
if(e.name == 'SequelizeUniqueConstraintError') { if (e.name == 'SequelizeUniqueConstraintError') {
return {code: 2, msg:"您的信息已经提交成功,请到我的订单中查看"}; return { code: 2, msg: "您的信息已经提交成功,请到我的订单中查看" };
} }
return { return {
code: -200, code: -200,
msg: "error", msg: "error",
data: {}, data: {},
stack : e.stack stack: e.stack
}; };
} }
} }
async buildOrder(obj, loginUser) { async buildOrder(obj, loginUser) {
var rs = {code: 0}; var rs = { code: 0 };
if(!loginUser) { if (!loginUser) {
rs.msg = "登录超时,请重新登录"; rs.msg = "登录超时,请重新登录";
return rs; return rs;
} }
if(!obj.idcard_front) { if (!obj.idcard_front) {
rs.msg = "请上传身份证正面图"; rs.msg = "请上传身份证正面图";
return rs; return rs;
} }
if(!obj.idcard_back) { if (!obj.idcard_back) {
rs.msg = "请上传身份证反面图"; rs.msg = "请上传身份证反面图";
return rs; return rs;
} }
if(!obj.idcard) { if (!obj.idcard) {
rs.msg = "请填写身份证号码"; rs.msg = "请填写身份证号码";
return rs; return rs;
} }
if(!await this.idcardClient.checkIDCard(obj.idcard)) { if (!await this.idcardClient.checkIDCard(obj.idcard)) {
} }
if(!obj.legal_name) { if (!obj.legal_name) {
rs.msg = "请填写法人姓名"; rs.msg = "请填写法人姓名";
return rs; return rs;
} }
if(!obj.legal_mobile) { if (!obj.legal_mobile) {
rs.msg = "请填写手机号码"; rs.msg = "请填写手机号码";
return rs; return rs;
} }
if(!obj.companyNames) { if (!obj.companyNames) {
rs.msg = "请填写公司名称"; rs.msg = "请填写公司名称";
return rs; return rs;
} }
if(!obj.bank_front) { if (!obj.bank_front) {
rs.msg = "请上传银行卡正面图"; rs.msg = "请上传银行卡正面图";
return rs; return rs;
} }
if(!obj.bank_back) { if (!obj.bank_back) {
rs.msg = "请上传银行卡反面图"; rs.msg = "请上传银行卡反面图";
return rs; return rs;
} }
if(!obj.bankMobile) { if (!obj.bankMobile) {
rs.msg = "请填写银行预留手机号"; rs.msg = "请填写银行预留手机号";
return rs; return rs;
} }
var orderNo = loginUser.id + "" + moment().format("YYYYMMDDHHmmss"); var orderNo = loginUser.id + "" + moment().format("YYYYMMDDHHmmss");
var order = { var order = {
merchantId : obj.merchantId, merchantId: obj.merchantId,
companyId : obj.companyId || 0, companyId: obj.companyId || 0,
orderNo : orderNo, orderNo: orderNo,
userId : loginUser.id, userId: loginUser.id,
ownerId: 0, ownerId: 0,
status: 0 status: 0,
auditStatus: 1
}; };
var userbiz = { var userbiz = {
merchantId : obj.merchantId, merchantId: obj.merchantId,
companyId : obj.companyId, companyId: obj.companyId,
orderNo: orderNo, orderNo: orderNo,
user_id: loginUser.id, user_id: loginUser.id,
idcard_front: obj.idcard_front, idcard_front: obj.idcard_front,
...@@ -243,12 +244,12 @@ class ChuangfuApplet extends AppletBase { ...@@ -243,12 +244,12 @@ class ChuangfuApplet extends AppletBase {
bank: obj.bank, bank: obj.bank,
bankno: obj.bankno, bankno: obj.bankno,
bankMobile: obj.bankMobile || "", bankMobile: obj.bankMobile || "",
businessScope:obj.businessScope || "" businessScope: obj.businessScope || ""
}; };
rs.code = 1; rs.code = 1;
rs.data = { rs.data = {
order : order, order: order,
userbiz: userbiz, userbiz: userbiz,
}; };
return rs; return rs;
...@@ -256,19 +257,19 @@ class ChuangfuApplet extends AppletBase { ...@@ -256,19 +257,19 @@ class ChuangfuApplet extends AppletBase {
async myOrders(gobj, pobj, req, loginUser) { async myOrders(gobj, pobj, req, loginUser) {
if(!loginUser) { if (!loginUser) {
return {code: 1, data:{count:0, rows:[]}}; return { code: 1, data: { count: 0, rows: [] } };
} }
try { try {
var params = { var params = {
pageSize: pobj.pageSize || 10, pageSize: pobj.pageSize || 10,
currentPage: pobj.currentPage || 1, currentPage: pobj.currentPage || 1,
userId: loginUser.id, userId: loginUser.id,
merchantId:this.merchantId merchantId: this.merchantId
} }
var page = await this.bmorderSve.pageByCondition(params); var page = await this.bmorderSve.pageByCondition(params);
var result = {code : 1, data: page}; var result = { code: 1, data: page };
return result; return result;
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e.stack);
...@@ -283,40 +284,40 @@ class ChuangfuApplet extends AppletBase { ...@@ -283,40 +284,40 @@ class ChuangfuApplet extends AppletBase {
code: -200, code: -200,
msg: "error", msg: "error",
data: {}, data: {},
stack : e.stack stack: e.stack
}; };
} }
} }
async idcardValid(gobj, pobj, req, loginUser){ async idcardValid(gobj, pobj, req, loginUser) {
try { try {
var idcard = (pobj.idcard || "").trim(); var idcard = (pobj.idcard || "").trim();
if(!idcard) { if (!idcard) {
return {code: 0, msg: "请填写身份证号码"}; return { code: 0, msg: "请填写身份证号码" };
} }
var isIdcard = await this.idcardClient.checkIDCard(idcard); var isIdcard = await this.idcardClient.checkIDCard(idcard);
if(isIdcard) { if (isIdcard) {
return {code: 1}; return { code: 1 };
} }
return {code: 0, msg: "身份证号码错误"}; return { code: 0, msg: "身份证号码错误" };
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return {code: 500, msg: "服务忙,请稍后重试"}; return { code: 500, msg: "服务忙,请稍后重试" };
} }
} }
async uploadConfig(gobj, pobj, req, loginUser){ async uploadConfig(gobj, pobj, req, loginUser) {
try { try {
if(!loginUser){ if (!loginUser) {
return {code: 0}; return { code: 0 };
} }
var openid = loginUser.openId; var openid = loginUser.openId;
var data = await this.uploadCtl.getOssConfig(); var data = await this.uploadCtl.getOssConfig();
return {code:1, data:data}; return { code: 1, data: data };
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return {code: 500}; return { code: 500 };
} }
} }
...@@ -327,23 +328,23 @@ class ChuangfuApplet extends AppletBase { ...@@ -327,23 +328,23 @@ class ChuangfuApplet extends AppletBase {
* @param {*} req * @param {*} req
* @param {*} loginUser * @param {*} loginUser
*/ */
async businessscopes(gobj, pobj, req, loginUser){ async businessscopes(gobj, pobj, req, loginUser) {
try { try {
let where ={}; let where = {};
if(loginUser){ if (loginUser) {
where.merchantId = loginUser.merchantId; where.merchantId = loginUser.merchantId;
}else{ } else {
where.merchantId = this.merchantId; where.merchantId = this.merchantId;
} }
let res = await this.bmmerchantbusinessscopeSve.dao.model.findAll({where:where}); let res = await this.bmmerchantbusinessscopeSve.dao.model.findAll({ where: where });
for (let item of res) { for (let item of res) {
item.dataValues.type = false; item.dataValues.type = false;
} }
return res; return res;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,`系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
...@@ -355,19 +356,19 @@ class ChuangfuApplet extends AppletBase { ...@@ -355,19 +356,19 @@ class ChuangfuApplet extends AppletBase {
* @param {*} loginUser * @param {*} loginUser
*/ */
async unauditOrders(gobj, pobj, req, loginUser) { async unauditOrders(gobj, pobj, req, loginUser) {
if(!loginUser) { if (!loginUser) {
return {code: 1, data:{count:0, rows:[]}}; return { code: 1, data: { count: 0, rows: [] } };
} }
try { try {
var params = { var params = {
pageSize: pobj.pageSize || 10, pageSize: pobj.pageSize || 10,
currentPage: pobj.currentPage || 1, currentPage: pobj.currentPage || 1,
auditStatus: pobj.auditStatus, auditStatus: pobj.auditStatus,
merchantId:this.merchantId, merchantId: this.merchantId,
} }
//0待审核 1审核通过 //0待审核 1审核通过
var page = await this.bmorderSve.unauditOrders(params); var page = await this.bmorderSve.unauditOrders(params);
var result = {code : 1, data: page}; var result = { code: 1, data: page };
return result; return result;
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e.stack);
...@@ -382,7 +383,7 @@ class ChuangfuApplet extends AppletBase { ...@@ -382,7 +383,7 @@ class ChuangfuApplet extends AppletBase {
code: -200, code: -200,
msg: "error", msg: "error",
data: {}, data: {},
stack : e.stack stack: e.stack
}; };
} }
} }
...@@ -394,18 +395,18 @@ class ChuangfuApplet extends AppletBase { ...@@ -394,18 +395,18 @@ class ChuangfuApplet extends AppletBase {
* @param {*} req * @param {*} req
* @param {*} loginUser * @param {*} loginUser
*/ */
async audit(gobj, pobj, req, loginUser){ async audit(gobj, pobj, req, loginUser) {
try { try {
let param = { let param = {
auditId:loginUser.id, auditId: loginUser.id,
rejectReason:this.trim(pobj.rejectReason) || "", rejectReason: this.trim(pobj.rejectReason) || "",
auditStatus:parseInt(pobj.auditStatus), auditStatus: parseInt(pobj.auditStatus),
id:this.trim(pobj.id) id: this.trim(pobj.id)
} }
return await this.bmorderSve.audit(param); return await this.bmorderSve.audit(param);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,error); return system.getResult(null, error);
} }
} }
...@@ -416,15 +417,15 @@ class ChuangfuApplet extends AppletBase { ...@@ -416,15 +417,15 @@ class ChuangfuApplet extends AppletBase {
* @param {*} req * @param {*} req
* @param {*} loginUser * @param {*} loginUser
*/ */
async updateOrder(gobj, pobj, req, loginUser){ async updateOrder(gobj, pobj, req, loginUser) {
if(!loginUser){ if (!loginUser) {
return system.getResult(null, `请先登陆`); return system.getResult(null, `请先登陆`);
} }
try { try {
//构建参数 //构建参数
var order = { var order = {
auditStatus:pobj.auditStatus, auditStatus: pobj.auditStatus || 1,
id:this.trim(pobj.id) id: this.trim(pobj.id)
}; };
let obj = pobj; let obj = pobj;
var userbiz = { var userbiz = {
...@@ -443,13 +444,13 @@ class ChuangfuApplet extends AppletBase { ...@@ -443,13 +444,13 @@ class ChuangfuApplet extends AppletBase {
businessScope: this.trim(obj.businessScope) businessScope: this.trim(obj.businessScope)
}; };
let params ={ let params = {
order,userbiz,loginUser order, userbiz, loginUser
} }
return await this.bmorderSve.updateOrder(params); return await this.bmorderSve.updateOrder(params);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,error); return system.getResult(null, error);
} }
} }
...@@ -460,15 +461,15 @@ class ChuangfuApplet extends AppletBase { ...@@ -460,15 +461,15 @@ class ChuangfuApplet extends AppletBase {
* @param {*} req * @param {*} req
* @param {*} loginUser * @param {*} loginUser
*/ */
async queryOrderInfo(gobj, pobj, req, loginUser){ async queryOrderInfo(gobj, pobj, req, loginUser) {
if(!loginUser){ if (!loginUser) {
return system.getResult(null, `请先登陆`); return system.getResult(null, `请先登陆`);
} }
try { try {
return await this.bmorderSve.queryOrderInfo(pobj); return await this.bmorderSve.queryOrderInfo(pobj);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,error); return system.getResult(null, error);
} }
} }
} }
......
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