Commit 905573b2 by 孙亚楠

dd

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