企业如何通过vue小程序开发满足高效运营与合规性需求
901
2022-11-27
thinkphp5 数据查询字段为type,转换为现有文字模型封装
第一种 控制器调用
$productModel = new ProductsModel();$userM = new UserModel();$main_data = $productModel->orderlist($where, $fields,$pro_data);print_r($main_data);foreach($main_data['rows'] as $key => $val){ $userInfo = $userM->get_user_info(['userid'=>$val['userid']],['user_name','real_name']); $main_data['rows'][$key]['user_name'] = $userInfo?$userInfo['user_name']:''; $main_data['rows'][$key]['real_name'] = $userInfo?$userInfo['real_name']:''; $main_data['rows'][$key]['pay_status'] = $productModel->getPayStatus($val['pay_status']); $main_data['rows'][$key]['remove_account_status'] = $productModel->getremove_account_status($val['pay_status']);}$stock_list = Db::table("daihou_case_pay_apply")->alias('a') ->join('daihou_case_info b', 'b.id = a.case_id', 'LEFT') ->join('hunuo_users c', 'c.user_id = a.personal_id', 'LEFT') ->field('b.collection_status,a.*,c.*') ->where($condition) ->group('a.id') ->order('user_id desc') ->limit($Page->firstRow . ',' . $Page->listRows) ->select();foreach ($stock_list as $key => $value) { $stock_list[$key]['approve_result'] = DaihouCasePayApply::getResult([$value['approve_result']]); $stock_list[$key]['approve_status'] = DaihouCasePayApply::getStatus([$value['approve_status']]); $stock_list[$key]['pay_way'] = DaihouCasePayApply::RepaymentType([$value['pay_way']]); $stock_list[$key]['pay_type'] = DaihouCasePayApply::RepaymentMethod([$value['pay_type']]);}
/**
* 转换type类型封装
*/
public static function getPayStatus($payStatus = ''){ $payStatusArr = array('10001' => '入账', '99991' => '待审核', '99992' => '驳回'); if (!empty($payStatus)) { if (!in_array($payStatus[0], array_keys($payStatusArr))) { return $payStatus; } else { return $payStatusArr[$payStatus[0]]; } } return $payStatusArr;}
第二种:
/** * 还款审批状态转换 */protected function explianType($value, $data){ $final = $value; $config = ['入账', '驳回']; if ($data['type']) { $fina = $config[$value]; } return $fina;}/** * 还款审批状态调用转换 */protected function getDseAttr($value, $data){ return $this->explianType($value, $data);}
第三种比较简单,利用tp的语言类转换
//订单状态$this->_LANG['order_status'] = array( '1' => '待审核', '80' => '待补充资料', '90' => '审批中', '100' => '审批通过', '110' => '审批不通过', '160' => '放款中', '161' => '贷款取消', '169' => '放款失败', '170' => '放款成功', '180' => '逾期', '200' => '贷款结清',);
$stock_list = Db::table("daihou_case_pay_apply")->alias('a') ->join('daihou_case_info b', 'b.id = a.case_id', 'LEFT') ->join('hunuo_users c', 'c.user_id = a.case_id', 'LEFT') ->field('b.collection_status,a.*,c.*') ->where($condition) ->group('a.id') ->order('a.id desc') ->limit($Page->firstRow . ',' . $Page->listRows) ->select(); foreach ($stock_list as $key => $value) { $user_data['pay_type'] = $this->_LANG['payment_type'][ $value['pay_type'] ] }
还一种比较简洁定义
static protected $methods = [ 'member' => 'masget.webapi.com.subcompany.add', 'getmember' => 'masget.webapi.com.subcompany.get', 'import' => 'masget.pay.compay.router.samename.open', 'order' => 'masget.pay.compay.router.back.pay', 'apply' => 'masget.pay.collect.router.treaty.apply', 'confirm' => 'masget.pay.collect.router.treaty.confirm', 'queryorder' => 'masget.pay.compay.router.paymentjournal.get', 'querypro' => 'masget.pay.collect.router.treaty.query', 'confirmpay' => 'masget.pay.compay.router.confirmpay', ];
直接在方法里面取
protected function PrepareParams($method, $data) { $method = self::$methods[$method]; }
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~