Commit a18f9213 by Sxy

feat: 财税项目询价

parent e32073a5
......@@ -22,6 +22,12 @@ class ProductAPI extends APIBase {
let rs = await this.productpriceS.findRegionsByProductName(pname, sp)
return system.getResult(rs);
}
async findProductInfoForFt(p, q, req) {
let pname = p.productname;
let region = p.region;
let rs = await this.productpriceS.findProductInfoForFt(pname, region)
return system.getResult(rs);
}
classDesc() {
return {
groupName: "auth",
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const _ = require("lodash");
class ProductpriceService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(ProductpriceService));
......@@ -8,7 +9,7 @@ class ProductpriceService extends ServiceBase {
* @param {*} pname 产品名称
* @param {*} spname 服务商名称
*/
async findRegionsByProductName (productname, spname) {
async findRegionsByProductName(productname, spname) {
let ps = await this.dao.model.findAll({
where: {
sptags: { [this.db.Op.like]: "%" + spname + "%" },
......@@ -53,7 +54,66 @@ class ProductpriceService extends ServiceBase {
})
return psrtn
}
async updownProduct (uid) {
/**
* 为 财税 提供 产品 详情 接口
* @param {*} productname 产品名称 小规模纳税人、一般纳税人
* @param {*} region 地区
* @param {*} spname 服务商
*/
async findProductInfoForFt(productname, region, spname = '公司宝') {
let datas = await this.dao.model.findAll({
where: {
$and: [
{
sptags: { $like: "%" + spname + "%" },
isEnabled: true,
pname: { $like: "%" + "财税服务" + "%" },
}, {
pname: { $like: "%" + "代理记账" + "%" }
}
]
},
attributes: ['pname', 'strategyitems', "hignpriceref"], // 价格、地区、skucode
raw: true
});
console.log(datas)
let result = [];
//查询出地区
let address = await this.db.models.region.findAll({ attributes: ['code', 'name'], raw: true });
for (let val of datas) {
let area = val.pname.split("~")[1].split("/");
area = area[area.length - 1];
//按照名字去取地区编码
let areaCode = address.filter(f => {
if (f.name.indexOf(area) >= 0) {
return true
} else {
return false
}
})
areaCode = `${areaCode[0].code}00`;
result.push({
area,
areaCode,
type: val.strategyitems,
price: val.hignpriceref
})
}
console.log(result);
result = _.groupBy(result, 'type')
if (productname) {
result = result[productname];
}
if (productname && region) {
result = _.find(result, (item) => {
return item.area.indexOf(region) >= 0
})
}
return result
}
async updownProduct(uid) {
let p = await this.dao.findById(uid)
p.isEnabled = !p.isEnabled
await p.save()
......
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