Commit 628c824e by 王昆

gsb

parent 936b0814
# Default ignored files
/workspace.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/zhichan.iml" filepath="$PROJECT_DIR$/.idea/zhichan.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
...@@ -2,6 +2,7 @@ var APIBase = require("../../api.base"); ...@@ -2,6 +2,7 @@ var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
const crypto = require('crypto'); const crypto = require('crypto');
const xlsx = require('node-xlsx'); const xlsx = require('node-xlsx');
class LaoActionApi extends APIBase { class LaoActionApi extends APIBase {
constructor() { constructor() {
super(); super();
...@@ -9,6 +10,7 @@ class LaoActionApi extends APIBase { ...@@ -9,6 +10,7 @@ class LaoActionApi extends APIBase {
this.logSve = system.getObject("service.operator.logSve"); this.logSve = system.getObject("service.operator.logSve");
this.recruitSve = system.getObject("service.operator.recruitSve"); this.recruitSve = system.getObject("service.operator.recruitSve");
this.labourSve = system.getObject("service.operator.labourSve"); this.labourSve = system.getObject("service.operator.labourSve");
this.workloadSve = system.getObject("service.common.workloadSve");
//this.uploadCtl = system.getObject("controller.common.uploadCtl"); //this.uploadCtl = system.getObject("controller.common.uploadCtl");
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
// this.restClient = system.getObject("util.restClient"); // this.restClient = system.getObject("util.restClient");
...@@ -40,30 +42,30 @@ class LaoActionApi extends APIBase { ...@@ -40,30 +42,30 @@ class LaoActionApi extends APIBase {
* @id 删除记录的id * @id 删除记录的id
* @type 删除类型 * @type 删除类型
*/ */
async RemRecOrLob(obj){ async RemRecOrLob(obj) {
if(!obj.type){ if (!obj.type) {
return system.getResult(-1, `参数错误 删除类型不能为空`); return system.getResult(-1, `参数错误 删除类型不能为空`);
} }
if(!obj.userId){ if (!obj.userId) {
return system.getResult(-1, `参数错误 用户ID不能为空`); return system.getResult(-1, `参数错误 用户ID不能为空`);
} }
if(!obj.id){ if (!obj.id) {
return system.getResult(-1, `参数错误 删除记录ID不能为空`); return system.getResult(-1, `参数错误 删除记录ID不能为空`);
} }
let params= {}; let params = {};
params.type=this.trim(obj.type); params.type = this.trim(obj.type);
params.userId=Number(this.trim(obj.userId)); params.userId = Number(this.trim(obj.userId));
params.id=Number(this.trim(obj.id)); params.id = Number(this.trim(obj.id));
try { try {
if(params.type=="10"){ //招聘的 if (params.type == "10") { //招聘的
return await this.recruitSve.RemRecOrLob(params); return await this.recruitSve.RemRecOrLob(params);
}else if(params.type=="20"){ //供人的 } else if (params.type == "20") { //供人的
return await this.labourSve.RemRecOrLob(params); return await this.labourSve.RemRecOrLob(params);
}else{ } else {
return system.getResult(-1,`参数错误 删除类型不存在`); return system.getResult(-1, `参数错误 删除类型不存在`);
} }
} catch (error) { } catch (error) {
return system.getResult(-1,`系统错误 错误信息 ${error}`); return system.getResult(-1, `系统错误 错误信息 ${error}`);
} }
} }
...@@ -87,7 +89,7 @@ class LaoActionApi extends APIBase { ...@@ -87,7 +89,7 @@ class LaoActionApi extends APIBase {
await this.redisClient.setWithEx(key, vcode, 5 * 60); await this.redisClient.setWithEx(key, vcode, 5 * 60);
await this.redisClient.setWithEx(key + "t", vcode, 60); await this.redisClient.setWithEx(key + "t", vcode, 60);
var msg = "您的验证码为" + vcode + ", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)"; var msg = "您的验证码为" + vcode + ", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)";
if(!isTest) { if (!isTest) {
var rs = await this.smsClient.sendMsg(phone_no, msg); var rs = await this.smsClient.sendMsg(phone_no, msg);
console.log(rs); console.log(rs);
} }
...@@ -126,10 +128,10 @@ class LaoActionApi extends APIBase { ...@@ -126,10 +128,10 @@ class LaoActionApi extends APIBase {
var key = this.vcodePrev + phone_no; var key = this.vcodePrev + phone_no;
var code = await this.redisClient.get(key) || ""; var code = await this.redisClient.get(key) || "";
if(!code) { if (!code) {
return system.getResult(null, "验证码已失效,请再1分钟之内输入"); return system.getResult(null, "验证码已失效,请再1分钟之内输入");
} }
if(vcode != code) { if (vcode != code) {
return system.getResult(null, "验证码错误,请重新输入"); return system.getResult(null, "验证码错误,请重新输入");
} }
var parm = { var parm = {
...@@ -284,8 +286,8 @@ class LaoActionApi extends APIBase { ...@@ -284,8 +286,8 @@ class LaoActionApi extends APIBase {
// if(obj.curStatus){ // if(obj.curStatus){
// parm.curStatus=this.trim(obj.curStatus); // parm.curStatus=this.trim(obj.curStatus);
// } // }
if(obj.curType){ if (obj.curType) {
parm.curType=this.trim(obj.curType); parm.curType = this.trim(obj.curType);
} }
if (find_type == 0) { if (find_type == 0) {
temp_info = await this.recruitSve.findAllList(parm); temp_info = await this.recruitSve.findAllList(parm);
...@@ -298,8 +300,7 @@ class LaoActionApi extends APIBase { ...@@ -298,8 +300,7 @@ class LaoActionApi extends APIBase {
} else if (find_type == 3) { } else if (find_type == 3) {
parm.counter_mark = obj.find_info; parm.counter_mark = obj.find_info;
temp_info = await this.recruitSve.findListByMark(parm); temp_info = await this.recruitSve.findListByMark(parm);
} } else if (find_type == 4) {
else if (find_type == 4){
parm.work_address = obj.find_info; parm.work_address = obj.find_info;
temp_info = await this.recruitSve.findListByAddress(parm); temp_info = await this.recruitSve.findListByAddress(parm);
} }
...@@ -329,21 +330,21 @@ class LaoActionApi extends APIBase { ...@@ -329,21 +330,21 @@ class LaoActionApi extends APIBase {
* 上架or下架 * 上架or下架
* @param {*} obj * @param {*} obj
*/ */
async UpdateCurStatus(obj){ async UpdateCurStatus(obj) {
//当前状态代码-1:展示中、2:已下架、3:已过期、4:审核未通过 cur_type //当前状态代码-1:展示中、2:已下架、3:已过期、4:审核未通过 cur_type
// if(!this.trim(obj.curStatus)){ // if(!this.trim(obj.curStatus)){
// return system.getResult(-1,`参数错误 状态不能为空`); // return system.getResult(-1,`参数错误 状态不能为空`);
// } // }
if(!Number(this.trim(obj.curType))){ if (!Number(this.trim(obj.curType))) {
return system.getResult(-1,`参数错误 状态码不能为空`); return system.getResult(-1, `参数错误 状态码不能为空`);
} }
if(!Number(this.trim(obj.id))){ if (!Number(this.trim(obj.id))) {
return system.getResult(-1,`参数错误 ID不能为空`); return system.getResult(-1, `参数错误 ID不能为空`);
} }
try { try {
return await this.recruitSve.UpdateCurStatus(obj); return await this.recruitSve.UpdateCurStatus(obj);
} catch (error) { } catch (error) {
return system.getResult(-1,`系统错误 错误信息 ${error}`); return system.getResult(-1, `系统错误 错误信息 ${error}`);
} }
} }
...@@ -503,27 +504,26 @@ class LaoActionApi extends APIBase { ...@@ -503,27 +504,26 @@ class LaoActionApi extends APIBase {
return system.getResult(null, "参数错误"); return system.getResult(null, "参数错误");
} }
try{ try {
if (obj.phone_no){ if (obj.phone_no) {
var phone_no = this.trim(obj.phone_no); var phone_no = this.trim(obj.phone_no);
if (!/^1[23456789]\d{9}$/.test(phone_no)) { if (!/^1[23456789]\d{9}$/.test(phone_no)) {
return system.getResult(null, "手机号码格式不正确"); return system.getResult(null, "手机号码格式不正确");
} }
if (obj.vcode){ if (obj.vcode) {
var vcode = this.trim(obj.vcode); var vcode = this.trim(obj.vcode);
var key = this.vcodePrev + phone_no; var key = this.vcodePrev + phone_no;
var code = await this.redisClient.get(key) || ""; var code = await this.redisClient.get(key) || "";
if(!code) { if (!code) {
return system.getResult(null, "验证码已失效,请再1分钟之内输入"); return system.getResult(null, "验证码已失效,请再1分钟之内输入");
} }
if(vcode != code) { if (vcode != code) {
return system.getResult(null, "验证码错误,请重新输入"); return system.getResult(null, "验证码错误,请重新输入");
} }
} } else {
else{
return system.getResult(null, "验证码为空,请输入验证码"); return system.getResult(null, "验证码为空,请输入验证码");
} }
...@@ -536,8 +536,7 @@ class LaoActionApi extends APIBase { ...@@ -536,8 +536,7 @@ class LaoActionApi extends APIBase {
} else { } else {
return system.getResult(null, "更新失败"); return system.getResult(null, "更新失败");
} }
} } catch {
catch{
return system.getResult(null, "更新失败!"); return system.getResult(null, "更新失败!");
} }
...@@ -606,7 +605,7 @@ class LaoActionApi extends APIBase { ...@@ -606,7 +605,7 @@ class LaoActionApi extends APIBase {
/** /**
* 定时更新招聘信息 * 定时更新招聘信息
*/ */
async UpdateRecruitExpired(){ async UpdateRecruitExpired() {
try { try {
await this.recruitSve.UpdateRecruitExpired(); await this.recruitSve.UpdateRecruitExpired();
} catch (error) { } catch (error) {
...@@ -614,8 +613,8 @@ class LaoActionApi extends APIBase { ...@@ -614,8 +613,8 @@ class LaoActionApi extends APIBase {
} }
} }
async ParamRecruitExcel(obj){ async ParamRecruitExcel(obj) {
if (!obj.userId || !obj.ossUrl){ if (!obj.userId || !obj.ossUrl) {
return system.getResult(null, "参数不能为空"); return system.getResult(null, "参数不能为空");
} }
var userId = obj.userId; var userId = obj.userId;
...@@ -628,134 +627,115 @@ class LaoActionApi extends APIBase { ...@@ -628,134 +627,115 @@ class LaoActionApi extends APIBase {
var rows = sheets[0].data; var rows = sheets[0].data;
for (var i = 5; i < rows.length; i++) { for (var i = 5; i < rows.length; i++) {
var cells = rows[i]; var cells = rows[i];
if (cells[0]){ if (cells[0]) {
var data = {}; var data = {};
data.recruit_name = "" + cells[1]; data.recruit_name = "" + cells[1];
data.recruit_type = "" + cells[2]; data.recruit_type = "" + cells[2];
data.recruit_count = "" + cells[3]; data.recruit_count = "" + cells[3];
data.pay_name = "" + cells[4]; data.pay_name = "" + cells[4];
if (data.pay_name == "月薪"){ if (data.pay_name == "月薪") {
data.pay_type = 1; data.pay_type = 1;
} } else if (data.pay_name == "日薪") {
else if (data.pay_name == "日薪"){
data.pay_type = 2; data.pay_type = 2;
} } else if (data.pay_name == "时薪") {
else if (data.pay_name == "时薪"){
data.pay_type = 3; data.pay_type = 3;
} } else {
else{
data.pay_type = null; data.pay_type = null;
} }
data.pay_unit = null;//少一个薪资单价 data.pay_unit = null;//少一个薪资单价
var temp = "" + cells[5]; var temp = "" + cells[5];
if (temp && temp != "—" && temp != "面议"){ if (temp && temp != "—" && temp != "面议") {
data.basic_salary = Number(temp) * 100; data.basic_salary = Number(temp) * 100;
} } else {
else{
data.basic_salary = null; data.basic_salary = null;
} }
temp = "" + cells[6]; temp = "" + cells[6];
if (temp && temp != "—" && temp != "面议"){ if (temp && temp != "—" && temp != "面议") {
data.compre_salary = Number(temp) * 100; data.compre_salary = Number(temp) * 100;
} } else {
else{
data.compre_salary = null; data.compre_salary = null;
} }
temp = "" + cells[7]; temp = "" + cells[7];
if (temp && temp != "—"){ if (temp && temp != "—") {
data.work_duration = Number(temp); data.work_duration = Number(temp);
} } else {
else{
data.work_duration = null; data.work_duration = null;
} }
temp = "" + cells[8]; temp = "" + cells[8];
if (temp == "面议"){ if (temp == "面议") {
data.rfee_type = 0; data.rfee_type = 0;
} } else if (temp == "月返") {
else if (temp == "月返"){
data.rfee_type = 1; data.rfee_type = 1;
} } else if (temp == "日返") {
else if (temp == "日返"){
data.rfee_type = 2; data.rfee_type = 2;
} } else if (temp == "时返") {
else if (temp == "时返"){
data.rfee_type = 3; data.rfee_type = 3;
} } else if (temp == "一次返") {
else if (temp == "一次返"){
data.rfee_type = 4; data.rfee_type = 4;
} } else {
else{
data.rfee_type = null; data.rfee_type = null;
} }
temp = "" + cells[9]; temp = "" + cells[9];
if (temp && temp != "—"){ if (temp && temp != "—") {
var arr = temp.split("/"); var arr = temp.split("/");
if (arr.length ==2){ if (arr.length == 2) {
data.rfee_duration = arr[0]; data.rfee_duration = arr[0];
data.rfee_time = arr[1]; data.rfee_time = arr[1];
} } else {
else{
data.rfee_duration = null; data.rfee_duration = null;
data.rfee_time = null; data.rfee_time = null;
} }
} } else {
else{
data.rfee_duration = null; data.rfee_duration = null;
data.rfee_time = null; data.rfee_time = null;
} }
temp = "" + cells[10]; temp = "" + cells[10];
if (temp){ if (temp) {
data.age_range = temp; data.age_range = temp;
} } else {
else{
data.age_range = null; data.age_range = null;
} }
temp = "" + cells[11]; temp = "" + cells[11];
if (temp){ if (temp) {
data.work_address = temp; data.work_address = temp;
} } else {
else{
data.work_address = null; data.work_address = null;
} }
data.publish_date = (new Date()).Format("yyyy-MM-dd"); data.publish_date = (new Date()).Format("yyyy-MM-dd");
temp = "" + cells[12]; temp = "" + cells[12];
if (temp){ if (temp) {
if (temp == "长期"){ if (temp == "长期") {
data.end_date = "1970-01-01"; data.end_date = "1970-01-01";
} } else {
else{
data.end_date = temp; data.end_date = temp;
} }
} } else {
else{
data.end_date = null; data.end_date = null;
} }
data.pic_path = null; data.pic_path = null;
temp = "" + cells[14]; temp = "" + cells[14];
if (temp){ if (temp) {
data.recrui_require = temp; data.recrui_require = temp;
} } else {
else{
data.recrui_require = null; data.recrui_require = null;
} }
temp = "" + cells[15]; temp = "" + cells[15];
if (temp){ if (temp) {
data.phone_no = temp; data.phone_no = temp;
} } else {
else{
data.phone_no = null; data.phone_no = null;
//data.user_id = null; //data.user_id = null;
} }
temp = "" + cells[14]; temp = "" + cells[14];
if (temp){ if (temp) {
var parm = { var parm = {
user_name: temp, user_name: temp,
find_type: 0, find_type: 0,
...@@ -765,19 +745,16 @@ class LaoActionApi extends APIBase { ...@@ -765,19 +745,16 @@ class LaoActionApi extends APIBase {
var user_info = await this.usersSve.findUserInfo(parm); var user_info = await this.usersSve.findUserInfo(parm);
if (user_info.status == -1) { if (user_info.status == -1) {
data.user_id = null; data.user_id = null;
} } else {
else{ if (user_info.count > 0) {
if (user_info.count > 0){
data.user_id = user_info.rows[0].id; data.user_id = user_info.rows[0].id;
} } else {
else{
data.user_id = null; data.user_id = null;
} }
} }
} } else {
else{
data.user_id = null; data.user_id = null;
} }
...@@ -797,12 +774,92 @@ class LaoActionApi extends APIBase { ...@@ -797,12 +774,92 @@ class LaoActionApi extends APIBase {
} else { } else {
return system.getResult(null, "插入数据失败"); return system.getResult(null, "插入数据失败");
} }
} } catch (e) {
catch (e){
console.log(e); console.log(e);
return system.getResult(null, "接口异常"); return system.getResult(null, "接口异常");
} }
}
// 工作量确认单
async paramXlsx(obj) {
try {
var rs = await this.workloadSve.paramXlsx(obj.userId, obj.ossUrl);
if (rs.code == 0) {
return system.getErrResult2(rs.msg || "文件解析失败");
}
return system.getResult2(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
// 列表
async workLoadPage(obj) {
try {
obj.status = 0;
var rs = await this.workloadSve.pageByCondition(obj);
return system.getResultSuccess(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
async workLoadHistoryInfo(obj) {
try {
var rs = await this.workloadSve.historyInfo(obj);
return system.getResultSuccess(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
// 确认/全部
async workloadConfirm(obj) {
try {
var rs = await this.workloadSve.workloadConfirm(obj);
return system.getResultSuccess(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
// 确认列表
async workloadHistory(obj) {
try {
obj.status = 0;
var rs = await this.workloadSve.historyPage(obj);
return system.getResultSuccess(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
// 企业信息,家属拒
async companyInfo() {
try {
let companyInfo = {
companyName: "上海韵达货运有限公司",
taxType: "一般纳税人",
contactName: "陈梁",
contactEmail: "chenliang8725@yundasys.com",
contactAddr: "上海市青浦区赵巷镇盈港东路6679号",
bankAccount: "上海韵达货运有限公司",
openBank: "邮政储蓄银行青浦支行",
bankno: "100360752790012735",
sign_body: "舟山兰和科技有限公司",
signBeginTime: "2019-08-26",
signEndTime: "2020-08-26",
};
return system.getResultSuccess(companyInfo);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
} }
async getOssConfig() { async getOssConfig() {
...@@ -835,6 +892,7 @@ class LaoActionApi extends APIBase { ...@@ -835,6 +892,7 @@ class LaoActionApi extends APIBase {
exam() { exam() {
return "xxx"; return "xxx";
} }
classDesc() { classDesc() {
return { return {
groupName: "auth", groupName: "auth",
...@@ -844,6 +902,7 @@ class LaoActionApi extends APIBase { ...@@ -844,6 +902,7 @@ class LaoActionApi extends APIBase {
exam: "", exam: "",
}; };
} }
methodDescs() { methodDescs() {
return [{ return [{
methodDesc: "生成访问token", methodDesc: "生成访问token",
...@@ -866,6 +925,7 @@ class LaoActionApi extends APIBase { ...@@ -866,6 +925,7 @@ class LaoActionApi extends APIBase {
}]; }];
} }
} }
module.exports = LaoActionApi; module.exports = LaoActionApi;
// var tesk = new LaoActionApi(); // var tesk = new LaoActionApi();
......
...@@ -83,20 +83,5 @@ class UploadCtl extends CtlBase{ ...@@ -83,20 +83,5 @@ class UploadCtl extends CtlBase{
// return system.getErrResult2("您的网络不稳, 请稍后重试") // return system.getErrResult2("您的网络不稳, 请稍后重试")
// } // }
// } // }
async paramXlsx(queryobj, qobj, req) {
try {
var rs = await this.workloadSve.paramXlsx(req.session.user.id, qobj.url);
if (rs.code == 0) {
return system.getErrResult2(rs.msg || "文件解析失败");
}
return system.getResult2(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
} }
module.exports=UploadCtl; module.exports=UploadCtl;
...@@ -223,6 +223,8 @@ class Dao { ...@@ -223,6 +223,8 @@ class Dao {
} }
return this.db.query(sql, tmpParas); return this.db.query(sql, tmpParas);
} }
async findCount(whereObj = null) { async findCount(whereObj = null) {
return this.model.count(whereObj, { logging: false }).then(c => { return this.model.count(whereObj, { logging: false }).then(c => {
return c; return c;
......
const system=require("../../../system"); const system = require("../../../system");
const Dao=require("../../dao.base"); const Dao = require("../../dao.base");
class WorkloadDao extends Dao{
constructor(){ class WorkloadDao extends Dao {
constructor() {
super(Dao.getModelName(WorkloadDao)); super(Dao.getModelName(WorkloadDao));
} }
async countHistory(params) {
var sql = [];
sql.push("SELECT COUNT(DISTINCT(id_nu)) AS num FROM `workload_info` WHERE status = 1");
this.setCondition(sql, params);
let rs = await this.customQuery(sql.join(" "), params);
if (!rs || rs.length == 0) {
return 0;
}
return rs[0].num || 0;
}
async pageHistory(params) {
var sql = [];
sql.push("SELECT");
sql.push("`id`, `username`, `iphone`, `id_nu`, `card_nu`, `send_amount`,");
sql.push("`created_at`, `updated_time`, `workload`, ");
sql.push("`created_time`, `updated_at`, `status`,");
sql.push("sum(send_amount) AS allAmount, COUNT(1) AS times");
sql.push("FROM `workload_info`")
sql.push("WHERE status = 1")
this.setCondition(sql, params);
sql.push("GROUP BY id_nu");
sql.push("LIMIT :startRow, :pageSize");
return await this.customQuery(sql.join(" "), params);
}
async findByIdNo(params) {
var sql = [];
sql.push("SELECT");
sql.push("`id`, `username`, `iphone`, `id_nu`, `card_nu`, `send_amount`,");
sql.push("`created_at`, `updated_time`, `workload`, ");
sql.push("`created_time`, `updated_at`, `status`");
sql.push("FROM `workload_info`");
sql.push("WHERE id_nu = :id_nu");
return await this.customQuery(sql.join(" "), params);
}
setCondition(sql, params) {
if (params.username) {
sql.push("AND username = :username");
}
if (params.iphone) {
sql.push("AND iphone = :iphone");
}
if (params.id_nu) {
sql.push("AND id_nu = :id_nu");
}
}
} }
module.exports=WorkloadDao;
module.exports = WorkloadDao;
...@@ -9,6 +9,98 @@ class WorkloadService extends ServiceBase { ...@@ -9,6 +9,98 @@ class WorkloadService extends ServiceBase {
this.restClient = system.getObject("util.restClient"); this.restClient = system.getObject("util.restClient");
} }
async pageByCondition(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var username = this.trim(params.username);
var iphone = this.trim(params.iphone);
var id_nu = this.trim(params.id_nu);
var status = this.trim(params.status);
var where = {};
var orderby = [
["id", 'desc']
];
if (username) {
where.username = username;
}
if (iphone) {
where.iphone = iphone;
}
if (id_nu) {
where.id_nu = id_nu
}
if (params.status === 0 || params.status === 1) {
where.status = params.status;
}
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
if (page && page.rows) {
for (var item of page.rows) {
this.handleDate(item, ['created_time', 'updated_time'], 'YYYY-MM-DD');
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
}
return page;
}
async workloadConfirm(params) {
var sql = [];
sql.push("UPDATE");
sql.push("workload_info");
sql.push("SET `status` = 1, updated_at = NOW()");
sql.push("WHERE `status` = 0");
if (params.id) {
sql.push("AND id = :id ");
}
await this.customUpdate(sql.join(" "), params);
return 1;
}
async historyPage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.username = this.trim(params.username);
params.iphone = this.trim(params.iphone);
params.id_nu = this.trim(params.id_nu);
params.status = this.trim(params.status);
let total = await this.dao.countHistory(params);
if (total == 0) {
return {count: 1, rows: []};
}
params.startRow = (params.currentPage - 1) * params.pageSize;
let list = await this.dao.pageHistory(params);
if (list) {
for (var item of list) {
this.handleDate(item, ['created_time', 'updated_time'], 'YYYY-MM-DD');
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
}
return {count: total, rows: list};
}
async historyInfo(params) {
let wl = await this.findById(params.id);
if (!wl) {
return [];
}
let list = await this.dao.findByIdNo({id_nu: wl.id_nu});
if (list) {
for (var item of list) {
this.handleDate(item, ['created_time', 'updated_time'], 'YYYY-MM-DD');
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
}
return list;
}
async paramXlsx(userId, ossurl) { async paramXlsx(userId, ossurl) {
var result = { var result = {
code: 0, code: 0,
...@@ -27,21 +119,26 @@ class WorkloadService extends ServiceBase { ...@@ -27,21 +119,26 @@ class WorkloadService extends ServiceBase {
} }
var heads = rows[0]; var heads = rows[0];
var cells = rows[i]; var cells = rows[i];
if (cells.length < 9) {
result.msg = "excel第" + i + "行,数据不全";
return result;
}
for (let j = 0; j < cells.length; j++) { for (let j = 0; j < cells.length; j++) {
if (cells[j] === undefined) { if (!cells[j]) {
result.msg = "excel序号为" + cells[0] + "的" + heads[j] + "不能为空"; result.msg = "excel序号为" + cells[0] + "的" + heads[j] + "不能为空";
return result; return result;
} }
} }
var data = {}; var data = {};
data.username = "" + cells[1]; data.username = this.trim(cells[1]);
data.iphone = "" + cells[2]; data.iphone = this.trim(cells[2]);
data.id_nu = "" + cells[3]; data.id_nu = this.trim(cells[3]);
data.card_nu = "" + cells[4]; data.card_nu = this.trim(cells[4]);
data.send_amount = "" + cells[5]; data.send_amount = this.trim(cells[5]);
data.created_time = "" + new Date(1900, 0, cells[6]); data.created_time = new Date(1900, 0, cells[6]);
data.updated_time = "" + new Date(1900, 0, cells[7]); data.updated_time = new Date(1900, 0, cells[7]);
data.workload = "" + cells[8]; data.workload = this.trim(cells[8]);
resu.push(data) resu.push(data)
} }
await this.dao.model.bulkCreate(resu, {fields: ["username", "iphone", "id_nu", "card_nu", "send_amount", "created_time", "updated_time", "workload"]}); await this.dao.model.bulkCreate(resu, {fields: ["username", "iphone", "id_nu", "card_nu", "send_amount", "created_time", "updated_time", "workload"]});
...@@ -53,10 +150,7 @@ class WorkloadService extends ServiceBase { ...@@ -53,10 +150,7 @@ class WorkloadService extends ServiceBase {
result.msg = "接口异常"; result.msg = "接口异常";
return result; return result;
} }
} }
} }
module.exports = WorkloadService; module.exports = WorkloadService;
\ No newline at end of file
...@@ -49,6 +49,9 @@ class ServiceBase { ...@@ -49,6 +49,9 @@ class ServiceBase {
async customQuery(sql, paras, t) { async customQuery(sql, paras, t) {
return this.dao.customQuery(sql, paras, t); return this.dao.customQuery(sql, paras, t);
} }
async customUpdate(sql, paras, t) {
return this.dao.customUpdate(sql, paras, t);
}
async findCount(whereObj = null) { async findCount(whereObj = null) {
return this.dao.findCount(whereObj); return this.dao.findCount(whereObj);
} }
...@@ -105,5 +108,30 @@ class ServiceBase { ...@@ -105,5 +108,30 @@ class ServiceBase {
} }
return uuid.join(''); return uuid.join('');
} }
handleDate(row, fields, pattern, addHours) {
pattern = pattern || "YYYY-MM-DD HH:mm:ss";
if (!row) {
return;
}
for (var field of fields) {
if (row[field]) {
if(addHours) {
row[field] = moment(row[field]).add(addHours,"hours").format(pattern);
} else {
row[field] = moment(row[field]).format(pattern);
}
}
}
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
} }
module.exports = ServiceBase; module.exports = ServiceBase;
...@@ -134,6 +134,37 @@ class System { ...@@ -134,6 +134,37 @@ class System {
} }
}; };
static y2f(y) {
if (!y) {
return 0;
}
return (Number(y) * 100).toFixed(0);
}
static f2y(f) {
if (!f) {
return 0;
}
return parseFloat((Number(f) / 100).toFixed(2));
}
static f2y4list(list, fields, prev) {
if (!list || list.length == 0 || !fields || fields.length == 0) {
return;
}
prev = prev || "";
for (var item of list) {
for (var f of fields) {
var v = item[f] || 0;
try {
item[f + "_y"] = prev + parseFloat((Number(v) / 100).toFixed(2));
} catch (error) {
console.log(error);
}
}
}
}
} }
Date.prototype.Format = function (fmt) { //author: meizz Date.prototype.Format = function (fmt) { //author: meizz
var o = { var o = {
......
...@@ -7,13 +7,13 @@ var settings={ ...@@ -7,13 +7,13 @@ var settings={
}, },
database:{ database:{
dbname : "laowubao", dbname : "laowubao",
user : "root", // user : "root",
password : "root", // password : "root",
// dbname : "laowubao", // dbname : "laowubao",
// user: "write", user: "write",
// password: "write", password: "write",
config : { config : {
host: '192.168.18.110', host: '192.168.18.237',
// dbname : "laowubao", // dbname : "laowubao",
// user: "write", // user: "write",
// password: "write", // password: "write",
......
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