You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.7 KiB
70 lines
1.7 KiB
<?php
|
|
namespace app\adminapi\controller\v1;
|
|
|
|
use app\adminapi\ApiController;
|
|
use think\facade\Db;
|
|
|
|
class Affiliate extends ApiController
|
|
{
|
|
public function getAffiliateConfig(){
|
|
$config = load_config();
|
|
|
|
$result = json_decode($config['affiliate'],true);
|
|
|
|
return $this->success($result);
|
|
}
|
|
|
|
public function setAffiliateConfig(){
|
|
$data = input('post.');
|
|
$dataJson = json_encode($data);
|
|
try{
|
|
Db::name('shop_config')->where('code','affiliate')->update(['value'=>$dataJson]);
|
|
}catch(\Exception $e){
|
|
return $this->error('操作失败');
|
|
}
|
|
|
|
return $this->success('操作成功');
|
|
}
|
|
|
|
public function getAffiliateList(){
|
|
$page = input('page');
|
|
$pageSize = input('pageSize');
|
|
|
|
$do = Db::name('affiliate_log')
|
|
->alias('al')
|
|
->leftjoin('order_info oi','oi.order_id = al.order_id')
|
|
->field('al.*,oi.order_sn,oi.order_amount');
|
|
|
|
|
|
$rtn = $do
|
|
->page($page, $pageSize)
|
|
->order('log_id', 'desc')
|
|
->select()
|
|
->toArray();
|
|
|
|
if (!$rtn) {
|
|
$rtn = [];
|
|
}
|
|
|
|
foreach ($rtn as $key => $val) {
|
|
$rtn[$key]['time'] = date('Y-m-d H:i:s', $val['time']);
|
|
}
|
|
|
|
$rtn = [
|
|
'total' => $do->count(),
|
|
'data' => $rtn
|
|
];
|
|
return $this->Success($rtn);
|
|
}
|
|
|
|
public function delAffiliateLog(){
|
|
$id=input('id');
|
|
try{
|
|
Db::name('affiliate_log')->where('log_id',$id)->delete();
|
|
}catch(\Exception $e){
|
|
return $this->Errot('删除失败');
|
|
}
|
|
return $this->Success('删除成功');
|
|
}
|
|
}
|