123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- namespace app\common\service;
- use app\common\constant\ApplyConstant;
- use app\common\constant\CommonConstant;
- use app\common\constant\ContractConstant;
- use app\common\constant\EvectionConstant;
- use app\common\constant\LeaveConstant;
- use app\common\constant\MaintainConstant;
- use app\common\constant\OfferConstant;
- use think\cache\driver\Redis;
- /**
- * 公共服务类
- */
- class CommonService
- {
- /**
- * 生成合同编号
- *
- * @param integer $type 合同类型
- **/
- public static function get_contract_no($type)
- {
- $options = config('redis.');
- $redis = new Redis($options);
- $key = 'dingtalk_contract_no';
- $key2 = 'dingtalk_contract_no_list';
- if ($redis->handler()->llen($key2) > 0) {
- $number = $redis->handler()->lpop($key2);
- } else {
- if ($redis->has($key)) {
- $number = $redis->get($key);
- } else {
- $number = 1;
- }
- $redis->set($key, $number + 1);
- }
- $new_number = filling_method($number, $number);
- $type_no = ContractConstant::get_type_no_list()[$type];
- $date = date('Ymd');
- $data = 'SET' . $type_no . $date . $new_number;
- return $data;
- }
- /**
- * 释放合同编号
- *
- * @param string $contract_no 合同编号
- **/
- public static function set_contract_no($contract_no)
- {
- $options = config('redis.');
- $redis = new Redis($options);
- $key2 = 'dingtalk_contract_no_list';
- return $redis->handler()->rpush($key2, substr($contract_no, 13));
- }
- /**
- * 重置合同编号
- **/
- public static function change_contract_no()
- {
- $options = config('redis.');
- $redis = new Redis($options);
- $key = 'dingtalk_contract_no';
- $key2 = 'dingtalk_contract_no_list';
- $key11 = $redis->set($key, 1);
- $key22 = $redis->rm($key2);
- return compact("key11","key22");
- }
- /**
- * 拼接查询字段
- *
- * @param string $field
- * @param string $aliasName
- */
- public static function getAliasField($field, $aliasName)
- {
- $field = explode(',', $field);
- foreach ($field as &$value) {
- $value = $aliasName . $value;
- }
- return $field;
- }
- /**
- * 判断用户是否是物业主管或信息负责人
- *
- * @param mixed $user 用户信息
- **/
- public static function isMaintain($user)
- {
- if (in_array($user['title'], MaintainConstant::get_type_title_list())) {
- return true;
- }
- return false;
- }
- /**
- * 类型数据
- */
- public static function get_data()
- {
- $module_list = get_one_two_array(CommonConstant::get_module_list(), 'id', 'name');
- $degree_list = get_one_two_array(OfferConstant::get_degree_list(), 'id', 'name');
- $pay_type_list = get_one_two_array(ApplyConstant::get_pay_type_list(), 'id', 'name');
- $time_list = get_one_two_array(LeaveConstant::get_time_list(), 'id', 'name');
- $data1 = get_one_two_array(ApplyConstant::get_type_list(), 'id', 'name');
- $data2 = get_one_two_array(OfferConstant::get_type_list(), 'id', 'name');
- $data5 = get_one_two_array(EvectionConstant::get_type_list(), 'id', 'name');
- $data6 = get_one_two_array(LeaveConstant::get_type_list(), 'id', 'name');
- $data8 = get_one_two_array(MaintainConstant::get_type_list(), 'id', 'name');
- $data9 = get_one_two_array(ContractConstant::get_type_list(), 'id', 'name');
- return compact("module_list", "degree_list", "pay_type_list", "time_list", "data1", "data2", "data5", "data6", "data8", "data9");
- }
- /**
- * 根据模块获取审批流项
- *
- * @param integer $module
- **/
- public static function get_item_list($module)
- {
- $get_item_list = [];
- switch ($module) {
- case CommonConstant::MODULE_5:
- $get_item_list = EvectionConstant::get_type_list();
- break;
- case CommonConstant::MODULE_6:
- $get_item_list = LeaveConstant::get_time_list();
- break;
- case CommonConstant::MODULE_8:
- $get_item_list = MaintainConstant::get_type_list();
- break;
- }
- return $get_item_list;
- }
- /**
- * 根据模块获取类型列表
- *
- * @param integer $module
- **/
- public static function get_type_list($module)
- {
- $list = [];
- switch ($module) {
- case CommonConstant::MODULE_1:
- $list = ApplyConstant::get_type_list();
- break;
- case CommonConstant::MODULE_2:
- $list = OfferConstant::get_type_list();
- break;
- case CommonConstant::MODULE_5:
- $list = EvectionConstant::get_type_list();
- break;
- case CommonConstant::MODULE_6:
- $list = LeaveConstant::get_type_list();
- break;
- case CommonConstant::MODULE_8:
- $list = MaintainConstant::get_type_list();
- break;
- case CommonConstant::MODULE_9:
- $list = ContractConstant::get_type_list();
- break;
- }
- return $list;
- }
- }
|