123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- class Payment extends BaseModel
- {
-
- const STATE_OPEN = 1;
-
- public function getPaymentInfo($condition = array())
- {
- return Db::name('payment')->where($condition)->find();
- }
-
- public function getPaymentOpenInfo($condition = array())
- {
- $condition[] = array('payment_state', '=', self::STATE_OPEN);
- return Db::name('payment')->where($condition)->find();
- }
-
- public function getPaymentList($condition = array())
- {
- return Db::name('payment')->where($condition)->select()->toArray();
- }
-
- public function getPaymentOpenList($condition = array())
- {
- $condition[] = array('payment_state', '=', self::STATE_OPEN);
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') == false) {
-
- $condition[] = array('payment_code', 'not in', array('wxpay_jsapi', 'wxpay_minipro', 'allinpay_h5'));
- } else {
-
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'miniprogram') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'miniProgram') !== false) {
- $condition[] = array('payment_code', 'not in', array('wxpay_h5', 'alipay_h5', 'wxpay_jsapi'));
- } else {
- $condition[] = array('payment_code', 'not in', array('wxpay_h5', 'alipay_h5'));
- }
- }
- return Db::name('payment')->where($condition)->select()->toArray();
- }
-
- public function addPayment($data)
- {
- return Db::name('payment')->insert($data);
- }
-
- public function delPayment($condition)
- {
- return Db::name('payment')->where($condition)->delete();
- }
-
- public function editPayment($data, $condition)
- {
- return Db::name('payment')->where($condition)->update($data);
- }
-
- public function getRowByCondition($conditionfield, $conditionvalue)
- {
- return Db::name('payment')->where($conditionfield, $conditionvalue)->find();
- }
-
- function get_builtin()
- {
- static $payments = null;
- if ($payments === null) {
- $payment_dir = PLUGINS_PATH . '/payments';
- $dir = dir($payment_dir);
- $payments = array();
- while (false !== ($entry = $dir->read())) {
-
- if ($entry{
- 0} == '.') {
- continue;
- }
-
- $payments[$entry] = $this->get_builtin_info($entry);
- }
- }
- return $payments;
- }
-
- function get_builtin_info($code)
- {
- $payment_path = PLUGINS_PATH . '/payments/' . $code . '/payment.info.php';
- return include($payment_path);
- }
- }
|