修改返利

This commit is contained in:
邹景立 2021-03-15 11:51:07 +08:00
parent 7c9b52de8e
commit d81074c33b
2 changed files with 28 additions and 13 deletions

View File

@ -286,7 +286,7 @@ class RebateCurrentService extends Service
$subsql = $this->app->db->name('DataUserUpgrade')->field('number')->whereLike('rebate_rule', '%,' . self::PRIZE_06 . ',%')->buildSql(true);
foreach ($this->app->db->name('DataUser')->where("vip_code in {$subsql}")->whereIn('id', $puids)->orderField('id', $puids)->cursor() as $user) {
if ($user['vip_code'] > $prevLevel) {
if (($amount = $this->_prize06amount($prevLevel, $user['vip_code'])) > 0) {
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']];
$name = "{$this->name(self::PRIZE_06)}[ {$prevLevel} > {$user['vip_code']} ]每单 {$amount}";
$this->app->db->name($this->table)->insert(array_merge($map, [
@ -302,8 +302,8 @@ class RebateCurrentService extends Service
/**
* 计算两等级之间的管理奖差异
* @param int $prevLevel
* @param int $nextLevel
* @param integer $prevLevel
* @param integer $nextLevel
* @return float
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
@ -311,15 +311,23 @@ class RebateCurrentService extends Service
*/
private function _prize06amount(int $prevLevel, int $nextLevel): float
{
$amount = 0.00;
foreach (range($prevLevel, $nextLevel) as $level) {
[$state, $value] = [
$this->config("manage_state_vip_{$level}"),
$this->config("manage_value_vip_{$level}"),
];
if ($state && $value > 0) $amount += $value;
if ($this->config("manage_type_vip_{$nextLevel}") == 2) {
$amount = 0.00;
foreach (range($prevLevel, $nextLevel) as $level) {
[$state, $value] = [
$this->config("manage_state_vip_{$level}"),
$this->config("manage_value_vip_{$level}"),
];
if ($state && $value > 0) $amount += $value;
}
return floatval($amount);
} else {
if ($this->config("manage_state_vip_{$nextLevel}")) {
return floatval($this->config("manage_value_vip_{$nextLevel}"));
} else {
return floatval(0);
}
}
return floatval($amount);
}
/**

View File

@ -249,9 +249,16 @@
{/if}
</legend>
<div class="layui-form-item nowrap">
{php} $key = 'manage_value_vip_'.$level['number']; {/php}
<input class="layui-input" type="hidden" name="upgrade_type_vip_{$level.number}" value="2">
{php} $key = 'manage_type_vip_'.$level['number']; {/php}
{php} $data[$key] = $data[$key] ?? 1; {/php}
{foreach [1 => '不累计未发管理奖金额',2 => '累计未发放管理奖金'] as $k => $v}
{if isset($data[$key]) and $data[$key] eq $k}
<input checked class="layui-input" type="radio" name="{$key}" value="{$k}" title="{$v}">
{else}
<input class="layui-input" type="radio" name="{$key}" value="{$k}" title="{$v}">
{/if}{/foreach}
<label class="block">
{php} $key = 'manage_value_vip_'.$level['number']; {/php}
<span class="color-blue"><b>请输入固定奖励金额</b> 如:比例填写 10.00 表示 10.00 </span>
<input class="layui-input" type="text" name="{$key}" data-blur-number="4" placeholder="请输入奖励金额或订单比例" value="{$data[$key]??'0.0000'}">
</label>