Commit 9f528e1f by 孙亚楠

ddg

parent e412c834
...@@ -7,6 +7,8 @@ class OrderCtl extends CtlBase { ...@@ -7,6 +7,8 @@ class OrderCtl extends CtlBase {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
this.orderSve = system.getObject("service.order.orderSve"); this.orderSve = system.getObject("service.order.orderSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
this.merchanttradeSve = system.getObject("service.merchant.merchanttradeSve");
// this.redisClient = system.getObject("util.redisClient"); // this.redisClient = system.getObject("util.redisClient");
} }
...@@ -23,13 +25,14 @@ class OrderCtl extends CtlBase { ...@@ -23,13 +25,14 @@ class OrderCtl extends CtlBase {
*/ */
async saveEorder(pobj, pobj2, req, res) { async saveEorder(pobj, pobj2, req, res) {
try{ try{
//TODO:首先拿到商户的账号信息 (拿到合同ID 合同名称 ) if(!pobj.merchant_id){
return system.getResult(null,`参数错误 商户ID不能为空`)
// TODO:需要去调用商户钱包 扣钱 }
if(!pobj.merchant_name){
return system.getResult(null,`参数错误 商户名称不能为空`)
}
//TODO:可能需要商户的合同ID和合同名称 //TODO:可能需要商户的合同ID和合同名称
if(!pobj.contract_url){ if(!pobj.contract_url){
return system.getResult(null, `参数错误 业务合同不能为空`); return system.getResult(null, `参数错误 业务合同不能为空`);
} }
...@@ -49,6 +52,13 @@ class OrderCtl extends CtlBase { ...@@ -49,6 +52,13 @@ class OrderCtl extends CtlBase {
if(pobj.product_type=='1'){ //如果是单个产品 需要转化单价 if(pobj.product_type=='1'){ //如果是单个产品 需要转化单价
pobj.product_unit_price = system.y2f(pobj.product_unit_price); pobj.product_unit_price = system.y2f(pobj.product_unit_price);
} }
// TODO:需要去调用商户钱包 扣钱
if(pobj.id){
let reduceAccountBalanceRes = await this.merchantaccountSve.addordelavailable({merchant_id: this.trim(pobj.merchant_id),amount:pobj.price*(-1)});
if(reduceAccountBalanceRes.status!=0){
return system.getResult(null, `扣款失败`);
}
}
//保存 //保存
let res = await this.orderSve.saveEorder(pobj); let res = await this.orderSve.saveEorder(pobj);
if(res.status==0 && res.data && res.data.price && res.data.product_type){ if(res.status==0 && res.data && res.data.price && res.data.product_type){
...@@ -86,7 +96,7 @@ class OrderCtl extends CtlBase { ...@@ -86,7 +96,7 @@ class OrderCtl extends CtlBase {
if(res.status==0){ if(res.status==0){
this.pushMerchantTrade(pobj); this.pushMerchantTrade(pobj);
} }
return system.getResult(res); return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
...@@ -98,15 +108,23 @@ class OrderCtl extends CtlBase { ...@@ -98,15 +108,23 @@ class OrderCtl extends CtlBase {
* @param params * @param params
*/ */
async pushMerchantTrade(params){ async pushMerchantTrade(params){
let orderBean = await this.orderSve.getEorderById({id: this.trim(id)}); let orderBean = await this.orderSve.getEorderById({id: this.trim(params.id)});
if(!orderBean){ if(orderBean.status!=0){
console.log(`推送流水失败 订单信息获取异常`); console.log(`推送流水失败 订单信息获取异常 订单信息:` + JSON.stringify(orderBean));
} }
orderBean = orderBean.data;
if(params.audit_status=='20'){ //订单审核成功 if(params.audit_status=='20'){ //订单审核成功
//TODO:推送给赵大哥 //TODO:推送给赵大哥
let res =await this.merchantaccountSve.reduceAccountBalance({merchant_id:orderBean.merchant_id,amount:orderBean.price});
if(res.status==0){
console.log("扣除余额成功 返回结果:" + JSON.stringify(res));
this.merchanttradeSve.valetorder({merchant_id:orderBean.merchant_id,amount:orderBean.price,trade_data_id:orderBean.id,trade_voucher:null});
}
} }
if(params.audit_status=='30'){ //订单审核失败 if(params.audit_status=='30'){ //订单审核失败
//TODO:推送给赵大哥 //TODO:推送给赵大哥
let reduceAccountBalanceRes = await this.merchantaccountSve.addordelavailable({merchant_id: this.trim(orderBean.merchant_id),amount:orderBean.price});
console.log("订单审核失败 余额退回 "+JSON.stringify(reduceAccountBalanceRes));
} }
} }
...@@ -125,7 +143,7 @@ class OrderCtl extends CtlBase { ...@@ -125,7 +143,7 @@ class OrderCtl extends CtlBase {
return system.getResult(null, `订单【${pobj.id}】不存在`); return system.getResult(null, `订单【${pobj.id}】不存在`);
} }
let res = await this.orderSve.getEorderById(pobj); let res = await this.orderSve.getEorderById(pobj);
return system.getResult(res); return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
...@@ -143,7 +161,19 @@ class OrderCtl extends CtlBase { ...@@ -143,7 +161,19 @@ class OrderCtl extends CtlBase {
async pageEorder(pobj, pobj2, req, res) { async pageEorder(pobj, pobj2, req, res) {
try{ try{
let res = await this.orderSve.pageEorder(pobj); let res = await this.orderSve.pageEorder(pobj);
return system.getResult(res); if(res.status!=0 || res.data.count==0){
return res;
}
for (let item of res.data.rows) {
item.price = system.f2y(item.price);
if(item.product_type=='1'){
item.product_unit_price = system.f2y(item.product_unit_price);
}
if(item.product_type=='2'){
item.product_specifications = system.f2y(item.product_specifications);
}
}
return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
...@@ -166,8 +196,6 @@ class OrderCtl extends CtlBase { ...@@ -166,8 +196,6 @@ class OrderCtl extends CtlBase {
return system.getResult(null, `参数错误 订单ID不能为空`); return system.getResult(null, `参数错误 订单ID不能为空`);
} }
try{ try{
//TODO:需要添加商户信息 (merchant_id)
return await this.orderSve.updEorderStatus(pobj); return await this.orderSve.updEorderStatus(pobj);
}catch (e) { }catch (e) {
console.log(e); console.log(e);
......
...@@ -2,11 +2,12 @@ var system = require("../../../system") ...@@ -2,11 +2,12 @@ var system = require("../../../system")
const settings = require("../../../../config/settings") const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
const moment = require('moment'); const moment = require('moment');
class OrderCtl extends CtlBase { class OrderauthlogCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
this.orderauthlogSve = system.getObject("service.order.orderauthlogSve"); this.orderauthlogSve = system.getObject("service.order.orderauthlogSve");
this.productSve = system.getObject("service.product.productSve");
} }
...@@ -58,15 +59,33 @@ class OrderCtl extends CtlBase { ...@@ -58,15 +59,33 @@ class OrderCtl extends CtlBase {
async pageEorderAuthLog(pobj, pobj2, req, res){ async pageEorderAuthLog(pobj, pobj2, req, res){
//如果存在时间筛选 时间格式 2020-05 //如果存在时间筛选 时间格式 2020-05
if(pobj.spendedDate){ if(pobj.spendedDate){
let dateRes = formatDate(pobj.spendedDate); let dateRes = this.formatDate(pobj.spendedDate);
pobj.spendedBegin = dateRes.spendedBegin; pobj.spendedBegin = dateRes.spendedBegin;
pobj.spendedEnd = dateRes.spendedEnd; pobj.spendedEnd = dateRes.spendedEnd;
} }
try{ try{
//TODO:需要获取当前商户信息 (商户ID) let res = await this.orderauthlogSve.pageEorderAuthLog(pobj);
pobj.merchant_id = "xxx";
return await this.orderauthlogSve.pageEorderAuthLog(pobj); if(res.status!=0 || res.data.count==0){
return res;
}
//格式化产品信息
let ids = [],productMap={};
for (let item of res.data.rows) {
ids.push(item.product_id);
}
let p_listRes = await this.productSve.getByIds({ids:ids});
if(p_listRes.status!=0){
return res;
}
//将产品列表映射成Map结构
for (let ele of p_listRes.data) {
productMap[ele.id]=ele;
}
for (let item of res.data.rows) {
item.product_info = productMap[item.product_id];
}
return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
...@@ -90,4 +109,4 @@ class OrderCtl extends CtlBase { ...@@ -90,4 +109,4 @@ class OrderCtl extends CtlBase {
} }
} }
module.exports = ProductCtl; module.exports = OrderauthlogCtl;
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ var system = require("../../../system") ...@@ -2,7 +2,7 @@ var system = require("../../../system")
const settings = require("../../../../config/settings") const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
class OrderCtl extends CtlBase { class OrderproductCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
...@@ -23,10 +23,10 @@ class OrderCtl extends CtlBase { ...@@ -23,10 +23,10 @@ class OrderCtl extends CtlBase {
if(!pobj.product_id){ if(!pobj.product_id){
return system.getResult(null, `参数错误 产品ID不能为空`); return system.getResult(null, `参数错误 产品ID不能为空`);
} }
if(!pobj.merchant_id){
return system.getResult(null, `获取数据错误`);
}
try{ try{
//TODO:需要获取当前商户信息 (商户ID)
pobj.merchant_id = "xxx";
return await this.orderproductSve.listEorderProduct(pobj); return await this.orderproductSve.listEorderProduct(pobj);
}catch (e) { }catch (e) {
console.log(e); console.log(e);
...@@ -43,9 +43,6 @@ class OrderCtl extends CtlBase { ...@@ -43,9 +43,6 @@ class OrderCtl extends CtlBase {
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}|void|*>} * @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}|void|*>}
*/ */
async listEorderProductByMerchantId(pobj, pobj2, req, res){ async listEorderProductByMerchantId(pobj, pobj2, req, res){
if(!pobj.product_id){
return system.getResult(null, `参数错误 产品ID不能为空`);
}
try{ try{
if(!pobj.merchant_id){ if(!pobj.merchant_id){
return system.getResult(null, `获取数据错误`); return system.getResult(null, `获取数据错误`);
...@@ -58,4 +55,4 @@ class OrderCtl extends CtlBase { ...@@ -58,4 +55,4 @@ class OrderCtl extends CtlBase {
} }
} }
module.exports = ProductCtl; module.exports = OrderproductCtl;
\ No newline at end of file \ No newline at end of file
...@@ -2,11 +2,12 @@ var system = require("../../../system") ...@@ -2,11 +2,12 @@ var system = require("../../../system")
const settings = require("../../../../config/settings") const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
const moment = require('moment'); const moment = require('moment');
class OrderCtl extends CtlBase { class OrdersignlogCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
this.ordersignlogSve = system.getObject("service.order.ordersignlogSve"); this.ordersignlogSve = system.getObject("service.order.ordersignlogSve");
this.productSve = system.getObject("service.product.productSve");
} }
/** /**
...@@ -19,24 +20,28 @@ class OrderCtl extends CtlBase { ...@@ -19,24 +20,28 @@ class OrderCtl extends CtlBase {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async saveEorderSignLog(pobj, pobj2, req, res){ async saveEorderSignLog(pobj, pobj2, req, res){
if(!params.order_id){ if(!pobj.order_id){
return system.getResult(null, `参数错误 订单ID不能为空`); return system.getResult(null, `参数错误 订单ID不能为空`);
} }
if(!params.product_id){ if(!pobj.product_id){
return system.getResult(null, `参数错误 产品ID不能为空`); return system.getResult(null, `参数错误 产品ID不能为空`);
} }
if(!params.engine_contract_name){ if(!pobj.engine_contract_name){
return system.getResult(null, `参数错误 签署任务名称不能为空`); return system.getResult(null, `参数错误 签署任务名称不能为空`);
} }
if(!params.engine_contract_id){ if(!pobj.engine_contract_id){
return system.getResult(null, `参数错误 签署ID不能为空`); return system.getResult(null, `参数错误 签署ID不能为空`);
} }
if(!params.actual_spend_name){ if(!pobj.actual_spend_name){
return system.getResult(null, `参数错误 实际使用方不能为空`); return system.getResult(null, `参数错误 实际使用方不能为空`);
} }
params.spended_num = Number(params.spended_num || 0); if(!pobj.platform_name){
params.spended_at = params.spended_at?params.spended_at:new Date(); return system.getResult(null, `参数错误 平台名称不能为空`);
params.platform_id=params.platform_id?params.platform_id:''; }
pobj.merchant_id = pobj.merchant_id ? this.trim(pobj.merchant_id) : '';
pobj.spended_num = Number(pobj.spended_num || 0);
pobj.spended_at = pobj.spended_at?pobj.spended_at:new Date();
pobj.platform_id=pobj.platform_id?pobj.platform_id:'';
try{ try{
return await this.ordersignlogSve.saveEorderSignLog(pobj); return await this.ordersignlogSve.saveEorderSignLog(pobj);
}catch (e) { }catch (e) {
...@@ -56,12 +61,32 @@ class OrderCtl extends CtlBase { ...@@ -56,12 +61,32 @@ class OrderCtl extends CtlBase {
async pageEorderSignLog(pobj, pobj2, req, res){ async pageEorderSignLog(pobj, pobj2, req, res){
//如果存在时间筛选 时间格式 2020-05 //如果存在时间筛选 时间格式 2020-05
if(pobj.spendedDate){ if(pobj.spendedDate){
let dateRes = formatDate(pobj.spendedDate); let dateRes = this.formatDate(pobj.spendedDate);
pobj.spendedBegin = dateRes.spendedBegin; pobj.spendedBegin = dateRes.spendedBegin;
pobj.spendedEnd = dateRes.spendedEnd; pobj.spendedEnd = dateRes.spendedEnd;
} }
try{ try{
return await this.ordersignlogSve.pageEorderSignLog(pobj); let res= await this.ordersignlogSve.pageEorderSignLog(pobj);
if(res.status!=0 || res.data.count==0){
return res;
}
//格式化产品信息
let ids = [],productMap={};
for (let item of res.data.rows) {
ids.push(item.product_id);
}
let p_listRes = await this.productSve.getByIds({ids:ids});
if(p_listRes.status!=0){
return res;
}
//将产品列表映射成Map结构
for (let ele of p_listRes.data) {
productMap[ele.id]=ele;
}
for (let item of res.data.rows) {
item.product_info = productMap[item.product_id];
}
return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
...@@ -85,4 +110,4 @@ class OrderCtl extends CtlBase { ...@@ -85,4 +110,4 @@ class OrderCtl extends CtlBase {
} }
} }
module.exports = ProductCtl; module.exports = OrdersignlogCtl;
\ No newline at end of file \ No newline at end of file
...@@ -33,6 +33,24 @@ class UserService extends ServiceBase { ...@@ -33,6 +33,24 @@ class UserService extends ServiceBase {
return await this.callms("sve_order", "getEorderById", params); return await this.callms("sve_order", "getEorderById", params);
} }
/**
* fn:查看订单列表(分页)
* @param params
* @returns {Promise<{msg: *, data, bizmsg: *|string, status: number}|any|undefined>}
*/
async pageEorder(params) {
return await this.callms("sve_order", "pageEorder", params);
}
/**
* fn:更爱订单状态
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any|undefined>}
*/
async updEorderStatus(params) {
return await this.callms("sve_order", "updEorderStatus", params);
}
......
...@@ -187,7 +187,7 @@ class System { ...@@ -187,7 +187,7 @@ class System {
let dev = "http://39.107.234.14"; let dev = "http://39.107.234.14";
return { return {
// 产品引擎 // 产品引擎
engine_product: local + ":3571" + path, engine_product: dev + ":3571" + path,
// 计费引擎 // 计费引擎
engine_fee: local + ":3572" + path, engine_fee: local + ":3572" + path,
// 认证引擎 // 认证引擎
...@@ -198,7 +198,7 @@ class System { ...@@ -198,7 +198,7 @@ class System {
// 用户服务 // 用户服务
sve_uc: dev + ":3651" + path, sve_uc: dev + ":3651" + path,
// 商户服务 // 商户服务
sve_merchant: local + ":3652" + path, sve_merchant: dev + ":3652" + path,
// 订单服务 // 订单服务
sve_order: local + ":3653" + path, sve_order: local + ":3653" + path,
} }
......
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