mb_payment.model.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * 手机支付方式
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class mb_paymentModel extends Model {
  11. //开启状态标识
  12. const STATE_OPEN = 1;
  13. public function __construct() {
  14. parent::__construct('mb_payment');
  15. }
  16. /**
  17. * 读取单行信息
  18. *
  19. * @param
  20. * @return array 数组格式的返回结果
  21. */
  22. public function getMbPaymentInfo($condition = array()) {
  23. $payment_info = $this->where($condition)->find();
  24. if (!empty($payment_info['payment_config'])) {
  25. $payment_info['payment_config'] = unserialize($payment_info['payment_config']);
  26. }
  27. if (isset($payment_info['payment_config']) && !is_array($payment_info['payment_config'])) {
  28. $payment_info['payment_config'] = array();
  29. }
  30. return $payment_info;
  31. }
  32. /**
  33. * 读开启中的取单行信息
  34. *
  35. * @param
  36. * @return array 数组格式的返回结果
  37. */
  38. public function getMbPaymentOpenInfo($condition = array()) {
  39. $condition['payment_state'] = self::STATE_OPEN;
  40. return $this->getMbPaymentInfo($condition);
  41. }
  42. /**
  43. * 读取多行
  44. *
  45. * @param
  46. * @return array 数组格式的返回结果
  47. */
  48. public function getMbPaymentList($condition = array()){
  49. $payment_list = $this->where($condition)->select();
  50. foreach ($payment_list as $key => $value) {
  51. if($value['payment_state'] == self::STATE_OPEN) {
  52. $payment_list[$key]['payment_state_text'] = '开启中';
  53. } else {
  54. $payment_list[$key]['payment_state_text'] = '关闭中';
  55. }
  56. }
  57. return $payment_list;
  58. }
  59. /**
  60. * 读取开启中的支付方式
  61. *
  62. * @param
  63. * @return array 数组格式的返回结果
  64. */
  65. public function getMbPaymentOpenList($condition = array()){
  66. $condition['payment_state'] = self::STATE_OPEN;
  67. return $this->getMbPaymentList($condition);
  68. }
  69. /**
  70. * 更新信息
  71. *
  72. * @param array $param 更新数据
  73. * @return bool 布尔类型的返回结果
  74. */
  75. public function editMbPayment($data, $condition){
  76. if(isset($data['payment_config'])) {
  77. $data['payment_config'] = serialize($data['payment_config']);
  78. }
  79. return $this->where($condition)->update($data);
  80. }
  81. }