Commit 14a3f542 by sxy

feat: 复购商机相关数据入库记录

parent 57c4464e
......@@ -25,9 +25,15 @@ class FgbusinesschanceAPI extends APIBase {
case "create": //创建复购商机
opResult = await this.fgbusinesschanceSve.create(pobj, pobj.actionBody);
break;
// case "getInfo": //获取商机
// opResult = await this.orderinfoSve.getInfo(pobj, pobj.actionBody);
// break;
case "createOrderRefundFq":
opResult = await this.fgbusinesschanceSve.createOrderRefundFq(pobj, pobj.actionBody);
break;
case "createOnlineProductClassificiationFq":
opResult = await this.fgbusinesschanceSve.createOnlineProductClassificiationFq(pobj, pobj.actionBody);
break;
case "createOrderInfoAndPayFq":
opResult = await this.fgbusinesschanceSve.createOrderInfoAndPayFq(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -8,14 +8,6 @@ class FgbusinesschancService extends ServiceBase {
super("dbcorder", "orderinfoDao");
}
//var sql = "select * from c_delivery_official_flow where sourceOrderNo IN(:sourceOrderNo)";
// var paramWhere = { sourceOrderNo: actionBody.sourceOrderNoList };
// var list = await this.customQuery(sql, paramWhere);
// putOrderDelivery(data, orderNo) {//修改交付信息
// var sql = "UPDATE `c_order_delivery` SET deliveryContent ='" + JSON.stringify(data) + "' where sourceOrderNo='" + orderNo + "'";
// sql = sql.replace('\n', '');
// this.customQuery(sql);
// }
async create(req, actionBody) {
var sql = "INSERT INTO `fg_businesschance` (`companyId` ,`crm_company_name`,`standard_company_name`,`businessId`,`created_at` ) VALUE (:companyId,:crm_company_name,:standard_company_name,:businessId,:created_at)";
await this.customInsert(sql, {
......@@ -27,19 +19,93 @@ class FgbusinesschancService extends ServiceBase {
});
return system.getResultSuccess();
};
// async getInfo(req, actionBody) {
// let sql = "select * from `fg_businesschance` where businessId=:businessId";
// var result = system.getResultSuccess();
// result.data = await this.customQuery(sql, {
// businessId: actionBody.businessId
// });
// return result
// };
// async updateStatus(req, actionBody) {
// var sql = "UPDATE `fg_businesschance` SET status=:status, stateName=:stateName where businessId=:businessId";
// await this.customUpdate(sql, actionBody);
// return system.getResultSuccess();
// }
// 创建order_refund_fq 记录
async createOrderRefundFq(req, actionBody) {
let sql = `INSERT INTO order_refund_fq (${Object.keys(actionBody).join()}) VALUE (:${Object.keys(actionBody).join(",:")})`;
await this.customInsert(sql, actionBody);
return system.getResultSuccess();
}
// 创建 online_product_classificiation_fq 记录
async createOnlineProductClassificiationFq(req, actionBody) {
let selectSql = `SELECT * FROM online_product_classificiation_fq WHERE product_id=:product_id`;
var list = await this.customQuery(selectSql, {
product_id: actionBody.product_id
});
let sql;
if (!list || list.length === 0) {
sql = `INSERT INTO online_product_classificiation_fq (${Object.keys(actionBody).join()}) VALUE (:${Object.keys(actionBody).join(",:")}) `;
await this.customInsert(sql, actionBody);
} else {
let values = [];
Object.keys(actionBody).forEach((item, index) => {
values.push(`${item}=:${item}`);
});
sql = `UPDATE online_product_classificiation_fq SET ${values.join()} WHERE product_id=:product_id`
await this.customUpdate(sql, actionBody);
}
return system.getResultSuccess();
}
// 创建 order_info_fq、pay_fq
async createOrderInfoAndPayFq(req, actionBody) {
let sql = `SELECT * FROM order_info_fq WHERE order_pkid =:order_pkid`;
let list = await this.customQuery(sql, {
order_pkid: actionBody.order_pkid
});
if (!list || list.length === 0) {
// 插入 order_info_fq
let data = {};
let keys = [
"order_pkid", "order_id",
"produce_first_type_pkid", "produce_first_type_name",
"produce_second_type_pkid", "produce_second_type_name",
"product_id", "product_name", "produce_price", "order_price",
"order_pay", "order_add_time", "order_update_time", "account_id",
"account_name", "account_region_province", "account_region_city",
"account_company_name", "owner_id", "owner_name", "supplier_id",
"ownership_company", "source", "source_type", "contract_number",
"contract_amount"];
keys.forEach((item, index) => {
if (actionBody[item]) {
data[item] = actionBody[item]
}
})
sql = `INSERT INTO order_info_fq (${Object.keys(data).join()}) VALUE (:${Object.keys(data).join(",:")}) `;
await this.customInsert(sql, data);
}
sql = `SELECT * FROM pay_fq WHERE order_no =:order_no`;
list = await this.customQuery(sql, {
order_no: actionBody.order_no
});
if (!list || list.length === 0) {
// 插入 pay_fq
let data = {};
let keys = [
"order_no", "amount",
"pay_time", "pay_way_id",
"pay_way_name", "pay_way_type",
"pay_period", "transaction_id",
"transaction_no", "creator_id",
"creator", "create_time",
"set_of_books_id", "set_of_books_name",
"owner_id", "owner_name", "supplier_id",
"ownership_company", "channel_source",
"remark", "payment_item_id"
];
keys.forEach((item, index) => {
if (actionBody[item]) {
data[item] = actionBody[item]
}
})
sql = `INSERT INTO pay_fq (${Object.keys(data).join()}) VALUE (:${Object.keys(data).join(",:")}) `;
await this.customInsert(sql, data);
}
return system.getResultSuccess();
}
}
module.exports = FgbusinesschancService;
\ No newline at end of file
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