Commit c2e348f9 by zhaoxiqing

gsb

parents c3bfb3f7 65c1c1c1
...@@ -27,7 +27,7 @@ class MerchantUserCtl extends CtlBase { ...@@ -27,7 +27,7 @@ class MerchantUserCtl extends CtlBase {
async merchantOfInfo(params, pobj2, req) { async merchantOfInfo(params, pobj2, req) {
try { try {
params.id = params.merchant_id; params.id = params.id || params.merchant_id;
let res = await this.merchantSve.merchantOfInfo(params); let res = await this.merchantSve.merchantOfInfo(params);
if (res.data) { if (res.data) {
await this.userSve.setRowsUser([res.data], "bd_id", "bd"); await this.userSve.setRowsUser([res.data], "bd_id", "bd");
......
...@@ -30,7 +30,15 @@ class MerchantaccountCtl extends CtlBase { ...@@ -30,7 +30,15 @@ class MerchantaccountCtl extends CtlBase {
async merchantAccountList(params, pobj2, req) { async merchantAccountList(params, pobj2, req) {
try { try {
return await this.merchantaccountSve.merchantAccountList(params); let page = await this.merchantaccountSve.merchantAccountList(params);
if(page.status!=0 ){
return page;
}
for (let item of page.data.rows) {
item.available_amount = system.f2y(item.available_amount);
item.balance_amount = system.f2y(item.balance_amount);
}
return page;
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
......
...@@ -14,6 +14,7 @@ class MerchantUserCtl extends CtlBase { ...@@ -14,6 +14,7 @@ class MerchantUserCtl extends CtlBase {
async merchanttradesOfList(params, pobj2, req) { async merchanttradesOfList(params, pobj2, req) {
try { try {
<<<<<<< HEAD
let resule = await this.merchanttradeSve.merchanttradesOfList(params); let resule = await this.merchanttradeSve.merchanttradesOfList(params);
if(resule.data.rows){ if(resule.data.rows){
...@@ -22,6 +23,16 @@ class MerchantUserCtl extends CtlBase { ...@@ -22,6 +23,16 @@ class MerchantUserCtl extends CtlBase {
} }
} }
return resule; return resule;
=======
let res = await this.merchanttradeSve.merchanttradesOfList(params);
if(res.status!=0){
return res;
}
for(let item of res.data.rows){
item.amount = system.f2y(item.amount);
}
return res;
>>>>>>> 65c1c1c1aab23279813d43a8a0fcaf5cd9edaaa5
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
...@@ -51,6 +62,7 @@ class MerchantUserCtl extends CtlBase { ...@@ -51,6 +62,7 @@ class MerchantUserCtl extends CtlBase {
//资金流水 //资金流水
async merchanttradesOfListAll(params, pobj2, req) { async merchanttradesOfListAll(params, pobj2, req) {
try { try {
<<<<<<< HEAD
let result = await this.merchanttradeSve.merchanttradesOfListAll(params); let result = await this.merchanttradeSve.merchanttradesOfListAll(params);
if(result.data.rows){ if(result.data.rows){
for(let item of result.data.rows){ for(let item of result.data.rows){
...@@ -59,6 +71,18 @@ class MerchantUserCtl extends CtlBase { ...@@ -59,6 +71,18 @@ class MerchantUserCtl extends CtlBase {
} }
} }
return result; return result;
=======
let res = await this.merchanttradeSve.merchanttradesOfListAll(params);
if(res.status!=0){
return res;
}
for(let item of res.data.rows){
item.amount = system.f2y(item.amount);
item.available_amount = system.f2y(item.available_amount);
item.balance_amount = system.f2y(item.balance_amount);
}
return res;
>>>>>>> 65c1c1c1aab23279813d43a8a0fcaf5cd9edaaa5
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
......
...@@ -7,6 +7,7 @@ class MerchantUserCtl extends CtlBase { ...@@ -7,6 +7,7 @@ class MerchantUserCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
this.merchantSve = system.getObject("service.merchant.merchantSve");
} }
async save(params, pobj2, req) { async save(params, pobj2, req) {
...@@ -29,6 +30,11 @@ class MerchantUserCtl extends CtlBase { ...@@ -29,6 +30,11 @@ class MerchantUserCtl extends CtlBase {
if (!params.mobile) { if (!params.mobile) {
return system.getResult(null, "请选择商户"); return system.getResult(null, "请选择商户");
} }
let merchantBean = await this.merchantSve.merchantOfInfo({id: this.trim(params.uctype_id)});
if(merchantBean.status!=0 || !merchantBean.data || merchantBean.data.audit_status!="1"){
return system.getResult(null, `商户【${params.uctype_id}】不存在`);
}
validation.check(params, "real_name", {name: "姓名", is_require: true}); validation.check(params, "real_name", {name: "姓名", is_require: true});
validation.check(params, "mobile", {name: "联系电话", is_require: true}); validation.check(params, "mobile", {name: "联系电话", is_require: true});
validation.check(params, "ucname", {name: "用户名", is_require: true}); validation.check(params, "ucname", {name: "用户名", is_require: true});
...@@ -53,11 +59,25 @@ class MerchantUserCtl extends CtlBase { ...@@ -53,11 +59,25 @@ class MerchantUserCtl extends CtlBase {
params.utype = 2; params.utype = 2;
params.uctype_id = this.trim(params.merchant_id); params.uctype_id = this.trim(params.merchant_id);
let res = await this.userSve.page(params); let res = await this.userSve.page(params);
let merchant_ids = new Set();
if (res.status === 0 && res.data && res.data.rows) { if (res.status === 0 && res.data && res.data.rows) {
for (let item of res.data.rows) { for (let item of res.data.rows) {
item.merchant = {id:"todo", name: "todo"}; // item.merchant = {id:"todo", name: "todo"};
merchant_ids.add(item.uctype_id);
} }
} }
if(merchant_ids.size==0){
return res;
}
let merchantDist = await this.merchantSve.merchantMapByIds({ids:Array.from(merchant_ids)});
if(merchantDist.status!=0 || !merchantDist.data){
return res;
}
merchantDist = merchantDist.data;
for (let item of res.data.rows) {
item.merchant_name = merchantDist[item.uctype_id] || "";
}
return res; return res;
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
......
...@@ -56,8 +56,17 @@ class OrderCtl extends CtlBase { ...@@ -56,8 +56,17 @@ 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);
} }
//格式化产品价格(组合产品 的子产品价格)
if(pobj.product_type=='2' && pobj.product_arr && pobj.product_arr.length>0){
for (let item of pobj.product_arr) {
item.price = system.y2f(item.price);
}
}
if(!pobj.product_name){
return system.getResult(null,`参数错误 产品名称不能为空`)
}
// 需要去调用商户钱包 扣钱 // 需要去调用商户钱包 扣钱
if(pobj.id){ if(!pobj.id){
let reduceAccountBalanceRes = await this.merchantaccountSve.addordelavailable({merchant_id: this.trim(pobj.merchant_id),amount:pobj.price*(-1)}); let reduceAccountBalanceRes = await this.merchantaccountSve.addordelavailable({merchant_id: this.trim(pobj.merchant_id),amount:pobj.price*(-1)});
if(reduceAccountBalanceRes.status!=0){ if(reduceAccountBalanceRes.status!=0){
return system.getResult(null, `扣款失败`); return system.getResult(null, `扣款失败`);
...@@ -67,11 +76,12 @@ class OrderCtl extends CtlBase { ...@@ -67,11 +76,12 @@ class OrderCtl extends CtlBase {
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){
res.data.price = system.f2y(res.data.price) || 0; res.data.price = system.f2y(res.data.price) || 0;
res.data.product_unit_price = system.f2y(res.data.product_unit_price) || 0;
if(res.data.product_type=='2'){ //如果是组合产品 if(res.data.product_type=='2'){ //如果是组合产品
res.data.product_specifications = system.f2y(res.data.product_specifications) || 0; res.data.product_specifications = system.f2y(res.data.product_specifications) || 0;
} }
} }
return system.getResult(res); return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
...@@ -122,13 +132,18 @@ class OrderCtl extends CtlBase { ...@@ -122,13 +132,18 @@ class OrderCtl extends CtlBase {
let res =await this.merchantaccountSve.reduceAccountBalance({merchant_id:orderBean.merchant_id,amount:orderBean.price}); let res =await this.merchantaccountSve.reduceAccountBalance({merchant_id:orderBean.merchant_id,amount:orderBean.price});
if(res.status==0){ if(res.status==0){
console.log("扣除余额成功 返回结果:" + JSON.stringify(res)); console.log("扣除余额成功 返回结果:" + JSON.stringify(res));
let res = await this.merchanttradeSve.valetorder({merchant_id:orderBean.merchant_id,amount:orderBean.price,trade_data_id:orderBean.id}); let _res = await this.merchanttradeSve.valetorder({merchant_id:orderBean.merchant_id,amount:orderBean.price,trade_data_id:orderBean.id,audit_status:"1"});
if(res.status==0 && res.data && res.data.id){ if(_res.status==0 && _res.data && _res.data.id){
console.log('交易流水创建完成 结果:' + JSON.stringify(res)); console.log('交易流水创建完成 结果:' + JSON.stringify(_res));
let r = await this.orderSve.updOrderSimple({id: orderBean.id, trade_id: res.data.id}); let r = await this.orderSve.updOrderSimple({id: orderBean.id, trade_id: _res.data.id});
console.log("更新交易流水ID完成 结果:"+JSON.stringify(r)); console.log("更新交易流水ID完成 结果:"+JSON.stringify(r));
} }
} }
// 计费引擎账户创建
let accountRes = await this.feeSve.createAccount({app_id: "100001", app_data_id: orderBean.id, balance: orderBean.product_specifications});
let engine_account_id = accountRes.data.account_id;
await this.orderSve.updOrderSimple({id: orderBean.id, engine_account_id: engine_account_id});
} }
if(params.audit_status=='30'){ //订单审核失败 if(params.audit_status=='30'){ //订单审核失败
// 推送给赵大哥 // 推送给赵大哥
...@@ -152,8 +167,14 @@ class OrderCtl extends CtlBase { ...@@ -152,8 +167,14 @@ 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);
if(res.status==0 && res.data.product_arr){
for(let item of res.data.product_arr){
item.price = system.f2y(item.price);
}
}
// 计费 // 计费
// await this.feeSve.setRowsFee([res.data], "engine_account_id"); // let feeRes = await this.feeSve.setRowsFee([res.data], "engine_account_id");
return res; return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
...@@ -189,7 +210,7 @@ class OrderCtl extends CtlBase { ...@@ -189,7 +210,7 @@ class OrderCtl extends CtlBase {
} }
let p_listRes = await this.productSve.getByIds({ids:ids}); let p_listRes = await this.productSve.getByIds({ids:ids});
if(p_listRes.status!=0){ if(p_listRes.status!=0){
return system.getResul(`获取订单产品失败`); return system.getResult(`获取订单产品失败`);
} }
//将产品列表映射成Map结构 //将产品列表映射成Map结构
for (let ele of p_listRes.data) { for (let ele of p_listRes.data) {
...@@ -199,7 +220,7 @@ class OrderCtl extends CtlBase { ...@@ -199,7 +220,7 @@ class OrderCtl extends CtlBase {
item.product_info = productMap[item.product_id]; item.product_info = productMap[item.product_id];
} }
// 设置计费内容 // 设置计费内容
// await this.feeSve.setRowsFee(res.data.rows, "engine_account_id"); await this.feeSve.setRowsFee(res.data.rows, "engine_account_id");
return res; return res;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
...@@ -231,22 +252,42 @@ class OrderCtl extends CtlBase { ...@@ -231,22 +252,42 @@ class OrderCtl extends CtlBase {
} }
/** /**
* fn:查看日志 * fn:查询商户下可用订单的产品
* @param pobj * @param pobj
* @param pobj2 * @param pobj2
* @param req * @param req
* @param res * @param res
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async pageEorderLog(pobj, pobj2, req, res){ async getMerchantLiveProduct(pobj, pobj2, req, res){
if(pobj.product_property=='1'){ if(!pobj.merchant_id){
return await this.orderauthlogCtl.pageEorderAuthLog(pobj); return system.getResult(null, `参数错误 商户ID不能为空`);
}else if(pobj.product_property=='2'){ }
return await this.ordersignlogSve.pageEorderSignLog(pobj); try{
}else{ return await this.orderSve.getMerchantLiveProduct(pobj);
return system.getResult(null, `参数错误 产品类型属性不存在`); }catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
} }
} }
/**
* fn:合同列表
* @param pobj
* @param pobj2
* @param req
* @param res
* @returns {Promise<void>}
*/
async pageEorderContract(pobj, pobj2, req, res){
try{
return await this.orderSve.pageEorderContract(pobj);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
}
} }
module.exports = OrderCtl; module.exports = OrderCtl;
\ No newline at end of file
...@@ -109,22 +109,7 @@ class OrdersignlogCtl extends CtlBase { ...@@ -109,22 +109,7 @@ class OrdersignlogCtl extends CtlBase {
return { spendedBegin,spendedEnd }; return { spendedBegin,spendedEnd };
} }
/**
* fn:合同列表
* @param pobj
* @param pobj2
* @param req
* @param res
* @returns {Promise<void>}
*/
async pageEorderContract(pobj, pobj2, req, res){
try{
return await this.ordersignlogSve.pageEorderContract(pobj);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
}
} }
module.exports = OrdersignlogCtl; module.exports = OrdersignlogCtl;
\ No newline at end of file
...@@ -10,6 +10,16 @@ class ProductCtl extends CtlBase { ...@@ -10,6 +10,16 @@ class ProductCtl extends CtlBase {
async getPage (pobj, pobj2, req) { async getPage (pobj, pobj2, req) {
try { try {
let res = await this.prodSve.getPage(pobj); let res = await this.prodSve.getPage(pobj);
if(res.status!=0 || !res.data || res.data.rows.length==0){
return res;
}
for(let item of res.data.rows){
if(item.product_type=='2'){
item.price = "分开计价";
}else if(item.product_type=='1'){
item.price = item.price + '元/份';
}
}
return res return res
} catch (error) { } catch (error) {
return system.getResultFail(500, err.message) return system.getResultFail(500, err.message)
......
...@@ -123,9 +123,12 @@ class FeeService extends ServiceBase { ...@@ -123,9 +123,12 @@ class FeeService extends ServiceBase {
} }
ids.push(id); ids.push(id);
} }
let map = await this.accountBulk({ids: ids}).data || {}; let map = await this.accountBulk({ids: ids});
map = map.data || {};
for (let item of rows) { for (let item of rows) {
item.fee = map[Number(item[field] || 0)] || {}; item.fee = map[Number(item[field] || 0)] || {balance:0};
item.allowance=Number(item.product_specifications) - Number(item.fee.balance || 0);
item.allowance = item.allowance < 0 ? 0 : item.allowance;
} }
} }
......
...@@ -45,6 +45,14 @@ class MerchantService extends ServiceBase { ...@@ -45,6 +45,14 @@ class MerchantService extends ServiceBase {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/**
* fn:根据商户ID查询商户信息MAP
* @returns {Promise<void>}
*/
async merchantMapByIds(params){
return await this.callms("sve_merchant", "merchantMapByIds", params);
}
} }
module.exports = MerchantService; module.exports = MerchantService;
...@@ -60,8 +60,23 @@ class UserService extends ServiceBase { ...@@ -60,8 +60,23 @@ class UserService extends ServiceBase {
return await this.callms("sve_order", "updOrderSimple", params); return await this.callms("sve_order", "updOrderSimple", params);
} }
/**
* fn:查询商户下可用订单的产品
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any|undefined>}
*/
async getMerchantLiveProduct(params){
return await this.callms("sve_order", "getMerchantLiveProduct", params);
}
/**
* fn:签署合同列表(分页)
* @param params
* @returns {Promise<void>}
*/
async pageEorderContract(params){
return await this.callms("sve_order", "pageEorderContract", params);
}
} }
......
...@@ -24,14 +24,7 @@ class UserService extends ServiceBase { ...@@ -24,14 +24,7 @@ class UserService extends ServiceBase {
return await this.callms("sve_order", "pageEorderSignLog", params); return await this.callms("sve_order", "pageEorderSignLog", params);
} }
/**
* fn:签署合同列表(分页)
* @param params
* @returns {Promise<void>}
*/
async pageEorderContract(params){
return await this.callms("sve_order", "pageEorderContract", params);
}
} }
module.exports = UserService; module.exports = UserService;
\ No newline at end of file
...@@ -184,22 +184,22 @@ class System { ...@@ -184,22 +184,22 @@ class System {
var path = "/api/op/action/springboard"; var path = "/api/op/action/springboard";
if (settings.env == "dev") { if (settings.env == "dev") {
let local = "http://127.0.0.1"; let local = "http://127.0.0.1";
let liangwenkai = "http://192.168.210.210"; let liangwenkai = "http://192.168.200.183";
let dev = "http://39.107.234.14"; let dev = "http://39.107.234.14";
return { return {
// 产品引擎 // 产品引擎
engine_product: liangwenkai + ":3571" + path, engine_product: dev + ":3571" + path,
// 计费引擎 // 计费引擎
engine_fee: local + ":3572" + path, engine_fee: dev + ":3572" + path,
// 认证引擎 // 认证引擎
engine_auth: local + ":3573" + path, engine_auth: dev + ":3573" + path,
// 签约引擎 // 签约引擎
engine_sign: local + ":3574" + path, engine_sign: dev + ":3574" + path,
// 用户服务 // 用户服务
sve_uc: dev + ":3651" + path, sve_uc: dev + ":3651" + path,
// 商户服务 // 商户服务
sve_merchant: dev + ":3652" + path, sve_merchant: local + ":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