69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\merchant\service;
|
||
|
|
||
|
use app\core\Service;
|
||
|
use think\admin\extend\CodeExtend;
|
||
|
|
||
|
/**
|
||
|
* 商户使用卡密
|
||
|
* Class CardService
|
||
|
* @package app\merchant\service
|
||
|
*/
|
||
|
class CardService extends Service
|
||
|
{
|
||
|
/**
|
||
|
* 设置默认操作表
|
||
|
* @var string
|
||
|
*/
|
||
|
public $table = 'merchant_card';
|
||
|
|
||
|
# 提交订单
|
||
|
public function up($card_id, $mid, $order_id, $card, $cash, $status = 1, $info = '', $msg = '')
|
||
|
{
|
||
|
$data = array();
|
||
|
$data['card_id'] = $card_id;
|
||
|
$data['mid'] = $mid;
|
||
|
$data['order_id'] = $order_id;
|
||
|
$state = $this->db()->where($data)->find();
|
||
|
if ($state) {
|
||
|
$update['card'] = $card;
|
||
|
$update['cash'] = $cash;
|
||
|
$update['status'] = $status;
|
||
|
$update['info'] = $info;
|
||
|
$update['msg'] = $msg;
|
||
|
$this->db()->where(array('id' => $state['id']))->update($update);
|
||
|
} else {
|
||
|
$data['card'] = $card;
|
||
|
$data['cash'] = $cash;
|
||
|
$data['status'] = $status;
|
||
|
$data['info'] = $info;
|
||
|
$data['msg'] = $msg;
|
||
|
$this->db()->insert($data);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public function getData($card_id, $status = false)
|
||
|
{
|
||
|
$where['card_id'] = $card_id;
|
||
|
if ($status) {
|
||
|
$where['status'] = $status;
|
||
|
}
|
||
|
$data = $this->db()->where($where)->order('id desc')->select();
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
public function getNum($card_id, $status = false)
|
||
|
{
|
||
|
$where['card_id'] = $card_id;
|
||
|
if ($status) {
|
||
|
$where['status'] = $status;
|
||
|
}
|
||
|
$data = $this->db()->where($where)->count('*');
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
}
|