Commit 3aabdf86 by 王昆

gsb

parent 5634da84
......@@ -11,6 +11,9 @@ class IborderService extends ServiceBase {
this.microsveClient = system.getObject("util.microsve.microsveClient");
this.businessmenDao = system.getObject("db.business.businessmenDao");
this.iborderbaseDao = system.getObject("db.order.iborderbaseDao");
this.paymentDao = system.getObject("db.order.paymentDao");
}
async api(params) {
......@@ -167,7 +170,6 @@ class IborderService extends ServiceBase {
}
}
// -----------------------以此间隔,上面为API下面为service---------------------------------
async createOrder(params, t) {
......@@ -199,6 +201,8 @@ class IborderService extends ServiceBase {
}
async completedOrder(params, t) {
let order = this.findById(params.id);
if (!order.legalName) {
return system.getResult(null, '法人姓名');
}
......@@ -229,7 +233,7 @@ class IborderService extends ServiceBase {
if (!order.businessType) {
return system.getResult(null, '经营范围');
}
if (!order.businessScop) {
if (!order.businessScope) {
return system.getResult(null, '经营范围详情');
}
if (!order.mailAddr) {
......@@ -242,6 +246,14 @@ class IborderService extends ServiceBase {
return system.getResult(null, '收件人电话');
}
order.isInfoComplete = true;
let orderBase = await this.iborderbaseDao.findById(params.id);
orderBase.isInfoComplete = true;
await order.save();
await orderBase.save();
return system.getResultSuccess();
}
async statTransData(params) {
......@@ -394,34 +406,38 @@ class IborderService extends ServiceBase {
}
async add(params) {
var order = {};
let order = {};
order.price = Number(params.price || 300000);
order.status = "1000";
var merchantId = params.merchantId || params.merchant_id;
let payStatus = 10;
let payType = 1;
let merchantId = params.merchantId || params.merchant_id;
if (merchantId) {
var exists = await this.dao.findOne({
let exists = await this.dao.findOne({
merchant_id: this.trim(merchantId),
channelOrderNo: this.trim(params.channelOrderNo),
});
if (exists) {
return system.getResult(null, "订单号【" + params.channelOrderNo + "】重复");
}
var merchantData = await this.microsveClient.call("merchant", "getById", {
let merchantData = await this.microsveClient.call("merchant", "getById", {
"id": merchantId
});
if (merchantData.status != 0) {
return merchantData;
}
var merchant = merchantData.data;
let merchant = merchantData.data;
if (!merchant.mustPay) {
order.price = 0;
order.status = "1020";
payStatus = 20; // 设置已支付
payType = 2; // 设置为按年支付
}
}
var busiStatus = await this.orderBusinessStatus.findOrderBusinessStatus(order.status);
let busiStatus = await this.orderBusinessStatus.findOrderBusinessStatus(order.status);
if (busiStatus) {
order.ostatus = busiStatus.ostatus;
}
......@@ -462,11 +478,38 @@ class IborderService extends ServiceBase {
order.userId = this.trim(params.userId);
// var baseOrder = {};
// baseOrder = await this.baseorderDao.create(baseOrder);
// order.id = baseOrder.id;
let baseOrder = {
merchant_id: merchantId,
businessmen_id: "",
channelNo: "qiye",
thirdNo: order.channelOrderNo,
productType: 1000,
bdId: order.bdId,
bdPath: order.bdPath,
price: order.price,
payStatus: payStatus,
status: 1000,
isInfoComplete: true,
};
order = await this.db.transaction(async t => {
baseOrder = await this.iborderbaseDao.create(baseOrder, t);
order.id = baseOrder.id;
let payment = {
order_id: baseOrder.id,
price: baseOrder.price,
channelName: "",
companyName: merchant.name,
payType: payType,
payStatus: "10",
};
payment = await this.paymentDao.create(payment, t);
params.orderpay_id = payment.id;
order = await this.dao.create(order);
order = await this.dao.create(order, t);
return order;
});
return system.getResultSuccess({
orderNo: order.id
});
......
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