修改奖励配置

This commit is contained in:
邹景立 2021-03-12 17:46:38 +08:00
parent b0891ee4a0
commit 5402cae0dc
2 changed files with 52 additions and 21 deletions

View File

@ -117,14 +117,16 @@ class RebateCurrentService extends Service
if ($this->app->db->name($this->table)->where($map)->count() > 0) return false;
if (!$this->checkLevelPrize(self::PRIZE_01, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "{$this->from1['id']}_{$this->user['id']}";
$map = ['type' => self::PRIZE_01, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
if (sysconf('shop.fristType') == 1) {
$amount = sysconf('shop.fristValue') ?: '0.00';
$name = self::instance()->name(self::PRIZE_01) . ",每人 {$amount}";
if ($this->config("frist_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("frist_value_vip_{$key}");
if ($this->config("frist_type_vip_{$key}") == 1) {
$amount = $value ?: '0.00';
$name = "{$this->name(self::PRIZE_01)},每人 {$amount}";
} else {
$amount = sysconf('shop.fristValue') * $this->order['amount_total'] / 100;
$name = self::instance()->name(self::PRIZE_01) . ",订单 " . sysconf('shop.fristValue') . '%';
$amount = $value * $this->order['amount_total'] / 100;
$name = "{$this->name(self::PRIZE_01)},订单 {$value}%";
}
$this->app->db->name($this->table)->insert(array_merge($map, [
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
@ -149,14 +151,16 @@ class RebateCurrentService extends Service
if ($this->app->db->name($this->table)->where($map)->count() < 1) return false;
if (!$this->checkLevelPrize(self::PRIZE_02, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "{$this->from1['id']}_{$this->user['id']}";
$map = ['type' => self::PRIZE_02, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
if (sysconf('shop.repeatType') == 1) {
$amount = sysconf('shop.repeatValue') ?: '0.00';
$name = self::instance()->name(self::PRIZE_02) . ",每人 {$amount}";
if ($this->config("repeat_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("repeat_value_vip_{$key}");
if ($this->config("repeat_type_vip_{$key}") == 1) {
$amount = $value ?: '0.00';
$name = "{$this->name(self::PRIZE_02)},每人 {$amount}";
} else {
$amount = sysconf('shop.repeatValue') * $this->order['amount_total'] / 100;
$name = self::instance()->name(self::PRIZE_02) . ",订单 " . sysconf('shop.repeatValue') . '%';
$amount = $value * $this->order['amount_total'] / 100;
$name = "{$this->name(self::PRIZE_02)},订单 {$value}%";
}
$this->app->db->name($this->table)->insert(array_merge($map, [
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
@ -179,10 +183,12 @@ class RebateCurrentService extends Service
if (empty($this->from1)) return false;
if (!$this->checkLevelPrize(self::PRIZE_03, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "{$this->user['id']}";
$map = ['type' => self::PRIZE_03, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
$amount = sysconf('shop.repeatValue') * $this->order['amount_total'] / 100;
$name = self::instance()->name(self::PRIZE_03) . ",订单 " . sysconf('shop.repeatValue') . '%';
if ($this->config("direct_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("direct_value_vip_{$key}");
$amount = $value * $this->order['amount_total'] / 100;
$name = "{$this->name(self::PRIZE_03)},订单 {$value}%";
$this->app->db->name($this->table)->insert(array_merge($map, [
'uid' => $this->from1['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
]));
@ -203,10 +209,12 @@ class RebateCurrentService extends Service
{
if (empty($this->from2)) return false;
if (!$this->checkLevelPrize(self::PRIZE_04, $this->from2['vip_code'])) return false;
$key = "{$this->user['id']}";
$map = ['type' => self::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
$amount = sysconf('shop.indirectValue') * $this->order['amount_total'] / 100;
$name = self::instance()->name(self::PRIZE_04) . ",订单 " . sysconf('shop.indirectValue') . '%';
if ($this->config("indirect_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("indirect_value_vip_{$key}");
$amount = $value * $this->order['amount_total'] / 100;
$name = "{$this->name(self::PRIZE_04)},订单 {$value}%";
$this->app->db->name($this->table)->insert(array_merge($map, [
'uid' => $this->from2['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
]));
@ -269,6 +277,29 @@ class RebateCurrentService extends Service
return true;
}
/**
* 升级奖励发放
*/
private function _prize07()
{
}
/**
* 获取配置数据
* @param ?string $name
* @return array|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function config(?string $name = null)
{
static $data = [];
if (empty($data)) $data = sysdata('RebateRule');
return is_null($name) ? $data : ($data[$name] ?? '');
}
/**
* 检查等级是否有奖励
* @param string $prize

View File

@ -12,8 +12,8 @@
<fieldset class="block">
<legend><span class="layui-badge">结算到账</span></legend>
<div class="layui-form-item">
{php} $data['settl_type'] = $data['settl_type'] ?? 0; {/php}
{foreach ['支付后立即到账', '确认收货后到账'] as $key => $val}{if $data.settl_type eq $key}
{php} $data['settl_type'] = $data['settl_type'] ?? 1; {/php}
{foreach [1 => '支付后立即到账',2 => '确认收货后到账'] as $key => $val}{if $data.settl_type eq $key}
<input checked class="layui-input" type="radio" name="settl_type" value="{$key}" title="{$val}">
{else}
<input class="layui-input" type="radio" name="settl_type" value="{$key}" title="{$val}">
@ -205,7 +205,7 @@
{/if}
</legend>
<div class="layui-form-item nowrap">
{php} $key = 'direct_value_vip_'.$level['number']; {/php}
{php} $key = 'indirect_value_vip_'.$level['number']; {/php}
<input class="layui-input" type="hidden" name="indirect_type_vip_{$level.number}" value="2">
<label class="block">
<span class="color-blue"><b>请输入团队业绩金额比例</b> 如:比例填写 10.00 表示 10.00% </span>