103 lines
3.1 KiB
PHP
103 lines
3.1 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\setting\service;
|
||
|
|
||
|
use app\core\Service;
|
||
|
use app\merchant\service\OrderHistoryService;
|
||
|
use app\merchant\service\OrderLastHistoryService;
|
||
|
use app\merchant\service\OrderLastweekHistoryService;
|
||
|
use app\merchant\service\OrderService;
|
||
|
use app\merchant\service\OrderTwoHistoryService;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 卡号黑名单
|
||
|
* Class BlackCardService
|
||
|
* @package app\channel\service
|
||
|
*/
|
||
|
class BlackCardService extends Service
|
||
|
{
|
||
|
/**
|
||
|
* 设置默认操作表
|
||
|
* @var string
|
||
|
*/
|
||
|
public $table = 'black_card';
|
||
|
|
||
|
# 添加黑名单
|
||
|
public function up($type, $value, $desc = '')
|
||
|
{
|
||
|
$where['type'] = $type;
|
||
|
$where['value'] = $value;
|
||
|
$info = $this->db()->where($where)->find();
|
||
|
|
||
|
$update['type'] = $type;
|
||
|
$update['value'] = $value;
|
||
|
$update['desc'] = $desc;
|
||
|
if (!$info) {
|
||
|
$update['status'] = 1;
|
||
|
$this->db()->insert($update);
|
||
|
} else {
|
||
|
$this->db()->where(array('id' => $info['id']))->update($update);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
# 验证数据是否可用
|
||
|
public function check($value)
|
||
|
{
|
||
|
$where['status'] = 1;
|
||
|
$data = $this->db()->where($where)->select()->toArray();
|
||
|
|
||
|
if ($data) {
|
||
|
foreach ($data as $k => $v) {
|
||
|
if ($v['type'] == 1 && $v['value'] == $value) {
|
||
|
return false;
|
||
|
} elseif ($v['type'] == 2 && strstr($value, $v['value'])) {
|
||
|
return false;
|
||
|
} elseif ($v['type'] == 3 && !strstr($value, $v['value'])) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
#验证订单是否拉黑是否可用
|
||
|
public function checkorderid($order_id,$merchant_type)
|
||
|
{
|
||
|
$orderService = OrderService::instance();
|
||
|
$order = $orderService->db()->field('param')->where(['order_id' => $order_id])->find();
|
||
|
if (!$order) {
|
||
|
$orderLastweekHistoryService = OrderLastweekHistoryService::instance();
|
||
|
$order = $orderLastweekHistoryService->db()->field('param')->where(['order_id' => $order_id])->find();
|
||
|
}
|
||
|
if (!$order) {
|
||
|
$orderLastHistoryService = OrderLastHistoryService::instance();
|
||
|
$order = $orderLastHistoryService->db()->field('param')->where(['order_id' => $order_id])->find();
|
||
|
}
|
||
|
if (!$order) {
|
||
|
$orderTwoHistoryService = OrderTwoHistoryService::instance();
|
||
|
$order = $orderTwoHistoryService->db()->field('param')->where(['order_id' => $order_id])->find();
|
||
|
}
|
||
|
if (!$order) {
|
||
|
$orderHistoryService = OrderHistoryService::instance();
|
||
|
$order = $orderHistoryService->db()->field('param')->where(['order_id' => $order_id])->find();
|
||
|
}
|
||
|
$param = json_decode($order['param'], true);
|
||
|
if (isset($param['By_OpenUid']) && $param['By_OpenUid'] != 'error') {
|
||
|
$value = $param['By_OpenUid'];
|
||
|
return $this->check($value);
|
||
|
}
|
||
|
|
||
|
if($merchant_type == 9){
|
||
|
if (isset($param['buyerId']) && $param['buyerId'] != 'error') {
|
||
|
$value = $param['buyerId'];
|
||
|
return $this->check($value);
|
||
|
}
|
||
|
}
|
||
|
return 'error';
|
||
|
|
||
|
}
|
||
|
}
|