mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-05-22 06:49:15 +08:00
统计调整返利
This commit is contained in:
parent
97be042add
commit
1a563d7baa
@ -31,10 +31,10 @@ class Rebate extends Auth
|
|||||||
|
|
||||||
$map = ['uid' => $this->uuid];
|
$map = ['uid' => $this->uuid];
|
||||||
$query = $this->_query($this->table)->where($map)->equal('type,status');
|
$query = $this->_query($this->table)->where($map)->equal('type,status');
|
||||||
$result = $query->whereLike('date', "{$date}%")->order('id desc')->page(true, false, false, 15);
|
$result = $query->whereLike('date', "{$date}-%")->order('id desc')->page(true, false, false, 15);
|
||||||
$result['total'] = [
|
$result['total'] = [
|
||||||
'年度' => $this->_query($this->table)->where($map)->equal('type,status')->whereLike('date', "{$year}%")->db()->sum('amount'),
|
'年度' => $this->_query($this->table)->where($map)->equal('type,status')->whereLike('date', "{$year}-%")->db()->sum('amount'),
|
||||||
'月度' => $this->_query($this->table)->where($map)->equal('type,status')->whereLike('date', "{$date}%")->db()->sum('amount'),
|
'月度' => $this->_query($this->table)->where($map)->equal('type,status')->whereLike('date', "{$date}-%")->db()->sum('amount'),
|
||||||
];
|
];
|
||||||
$this->success('获取返利统计', $result);
|
$this->success('获取返利统计', $result);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace app\data\service;
|
namespace app\data\service;
|
||||||
|
|
||||||
use think\admin\Exception;
|
use think\admin\Exception;
|
||||||
|
use think\admin\extend\CodeExtend;
|
||||||
use think\admin\Service;
|
use think\admin\Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,9 +153,8 @@ class RebateService extends Service
|
|||||||
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
||||||
$name = "{$this->name(self::PRIZE_01)},订单 {$value}%";
|
$name = "{$this->name(self::PRIZE_01)},订单 {$value}%";
|
||||||
}
|
}
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
// 写入返利记录
|
||||||
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $val, 'status' => $this->status, 'order_amount' => $this->order['amount_total'],
|
$this->create($this->from1['id'], $map, $name, $val);
|
||||||
]));
|
|
||||||
// 更新用户奖利金额
|
// 更新用户奖利金额
|
||||||
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
||||||
}
|
}
|
||||||
@ -186,9 +186,8 @@ class RebateService extends Service
|
|||||||
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
||||||
$name = "{$this->name(self::PRIZE_02)},订单 {$value}%";
|
$name = "{$this->name(self::PRIZE_02)},订单 {$value}%";
|
||||||
}
|
}
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
// 写入返利记录
|
||||||
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $val, 'status' => $this->status, 'order_amount' => $this->order['amount_total'],
|
$this->create($this->from1['id'], $map, $name, $val);
|
||||||
]));
|
|
||||||
// 更新用户奖利金额
|
// 更新用户奖利金额
|
||||||
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
||||||
}
|
}
|
||||||
@ -213,9 +212,8 @@ class RebateService extends Service
|
|||||||
$value = $this->config("direct_value_vip_{$key}");
|
$value = $this->config("direct_value_vip_{$key}");
|
||||||
$name = "{$this->name(self::PRIZE_03)},订单 {$value}%";
|
$name = "{$this->name(self::PRIZE_03)},订单 {$value}%";
|
||||||
$amount = floatval($value * $this->order['rebate_amount'] / 100);
|
$amount = floatval($value * $this->order['rebate_amount'] / 100);
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
// 写入返利记录
|
||||||
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $amount, 'status' => $this->status, 'order_amount' => $this->order['amount_total'],
|
$this->create($this->from1['id'], $map, $name, $amount);
|
||||||
]));
|
|
||||||
// 更新用户奖利金额
|
// 更新用户奖利金额
|
||||||
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
||||||
}
|
}
|
||||||
@ -237,11 +235,10 @@ class RebateService extends Service
|
|||||||
$map = ['type' => self::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
$map = ['type' => self::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||||
if ($this->config("indirect_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
|
if ($this->config("indirect_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
|
||||||
$value = $this->config("indirect_value_vip_{$key}");
|
$value = $this->config("indirect_value_vip_{$key}");
|
||||||
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
|
||||||
$name = "{$this->name(self::PRIZE_04)},订单 {$value}%";
|
$name = "{$this->name(self::PRIZE_04)},订单 {$value}%";
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
$amount = floatval($value * $this->order['rebate_amount'] / 100);
|
||||||
'uid' => $this->from2['id'], 'name' => $name, 'amount' => $val, 'status' => $this->status, 'order_amount' => $this->order['amount_total'],
|
// 写入返利记录
|
||||||
]));
|
$this->create($this->from2['id'], $map, $name, $amount);
|
||||||
// 更新代理奖利金额
|
// 更新代理奖利金额
|
||||||
UserUpgradeService::instance()->upgrade($this->from2['id']);
|
UserUpgradeService::instance()->upgrade($this->from2['id']);
|
||||||
}
|
}
|
||||||
@ -276,14 +273,12 @@ class RebateService extends Service
|
|||||||
];
|
];
|
||||||
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
|
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
|
||||||
$dRate = ($tRate - $rule['discount']) / 100;
|
$dRate = ($tRate - $rule['discount']) / 100;
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
$name = "等级差额奖励{$tVip}#{$user['vip_code']}商品的{$dRate}%";
|
||||||
'name' => "等级差额奖励{$tVip}#{$user['vip_code']}商品的{$dRate}%",
|
$amount = $dRate * $item['total_selling'];
|
||||||
'amount' => $dRate * $item['total_selling'],
|
// 写入返利记录
|
||||||
'status' => $this->status,
|
$this->create($user['id'], $map, $name, $amount);
|
||||||
'order_no' => $this->order['order_no'],
|
// 更新用户奖利金额
|
||||||
'order_uid' => $this->order['uid'],
|
UserRebateService::instance()->amount($user['id']);
|
||||||
'order_amount' => $this->order['amount_total'],
|
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
[$tVip, $tRate] = [$user['vip_code'], $rule['discount']];
|
[$tVip, $tRate] = [$user['vip_code'], $rule['discount']];
|
||||||
}
|
}
|
||||||
@ -313,10 +308,10 @@ class RebateService extends Service
|
|||||||
if (($amount = $this->_prize06amount($prevLevel, $user['vip_code'])) > 0.00) {
|
if (($amount = $this->_prize06amount($prevLevel, $user['vip_code'])) > 0.00) {
|
||||||
$map = ['type' => self::PRIZE_06, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
$map = ['type' => self::PRIZE_06, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||||
$name = "{$this->name(self::PRIZE_06)},[ {$prevLevel} > {$user['vip_code']} ]每单 {$amount} 元";
|
$name = "{$this->name(self::PRIZE_06)},[ {$prevLevel} > {$user['vip_code']} ]每单 {$amount} 元";
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
// 写入返利记录
|
||||||
'uid' => $this->from2['id'], 'name' => $name, 'amount' => $amount, 'status' => $this->status, 'order_amount' => $this->order['amount_total'],
|
$this->create($user['id'], $map, $name, $amount);
|
||||||
]));
|
// 更新用户奖利金额
|
||||||
UserUpgradeService::instance()->upgrade($this->from2['id']);
|
UserUpgradeService::instance()->upgrade($user['id']);
|
||||||
}
|
}
|
||||||
$prevLevel = $user['vip_code'];
|
$prevLevel = $user['vip_code'];
|
||||||
}
|
}
|
||||||
@ -374,9 +369,8 @@ class RebateService extends Service
|
|||||||
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
$val = floatval($value * $this->order['rebate_amount'] / 100);
|
||||||
$name = "{$this->name(self::PRIZE_07)},订单 {$value}%";
|
$name = "{$this->name(self::PRIZE_07)},订单 {$value}%";
|
||||||
}
|
}
|
||||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
// 写入返利记录
|
||||||
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $val, 'status' => $this->status, 'order_amount' => $this->order['amount_total'],
|
$this->create($this->from1['id'], $map, $name, $val);
|
||||||
]));
|
|
||||||
// 更新用户奖利金额
|
// 更新用户奖利金额
|
||||||
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
UserUpgradeService::instance()->upgrade($this->from1['id']);
|
||||||
}
|
}
|
||||||
@ -398,6 +392,28 @@ class RebateService extends Service
|
|||||||
return is_null($name) ? $data : ($data[$name] ?? '');
|
return is_null($name) ? $data : ($data[$name] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写返利记录
|
||||||
|
* @param int $uid
|
||||||
|
* @param array $map
|
||||||
|
* @param string $name
|
||||||
|
* @param float $amount
|
||||||
|
*/
|
||||||
|
public function create(int $uid, array $map, string $name, float $amount)
|
||||||
|
{
|
||||||
|
$this->app->db->name($this->table)->insert(array_merge($map, [
|
||||||
|
'uid' => $uid,
|
||||||
|
'date' => date('Y-m-d'),
|
||||||
|
'code' => CodeExtend::uniqidDate(20, 'R'),
|
||||||
|
'name' => $name,
|
||||||
|
'amount' => $amount,
|
||||||
|
'status' => $this->status,
|
||||||
|
'order_no' => $this->order['order_no'],
|
||||||
|
'order_uid' => $this->order['uid'],
|
||||||
|
'order_amount' => $this->order['amount_total'],
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查等级是否有奖励
|
* 检查等级是否有奖励
|
||||||
* @param string $prize 奖励规则
|
* @param string $prize 奖励规则
|
||||||
|
Loading…
x
Reference in New Issue
Block a user