优化发放

master
chenzhi 3 years ago
parent 83822e7952
commit bc19bec4b1

@ -874,6 +874,7 @@ class MarketPercentageController extends ThinkController
// //
$data[$key]['should_performance_commission'] = number_format($value["performance_commission"] * ($market_percentage["performance_monthly_ratio"]/100), 2, '.', '')+$this->returnMarketPercentageArray[$value['admin_id'].$value['pay_time']]['performance_commission']; $data[$key]['should_performance_commission'] = number_format($value["performance_commission"] * ($market_percentage["performance_monthly_ratio"]/100), 2, '.', '')+$this->returnMarketPercentageArray[$value['admin_id'].$value['pay_time']]['performance_commission'];
$data[$key]['extend_commission'] += $this->returnMarketPercentageArray[$value['admin_id'].$value['pay_time']]['performance_commission']+$this->returnMarketPercentageArray[$value['admin_id'].$value['pay_time']]['achievement_bonus']; $data[$key]['extend_commission'] += $this->returnMarketPercentageArray[$value['admin_id'].$value['pay_time']]['performance_commission']+$this->returnMarketPercentageArray[$value['admin_id'].$value['pay_time']]['achievement_bonus'];
$data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'], 2, '.', ''); $data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'], 2, '.', '');

@ -4,9 +4,11 @@ namespace base\Factory;
class MarketPercentageFactory { class MarketPercentageFactory {
protected $coefficients = []; protected $coefficients = [];
protected $groupid = [];
//实例化离职服务类 //实例化离职服务类
public function __construct() public function __construct()
{ {
$this->groupid = A("Admin/Market","Event")->getMarketGroupId();
$this->coefficients = []; $this->coefficients = [];
$coefficient_data = M("coefficient", "tab_")->where("1=1")->select(); $coefficient_data = M("coefficient", "tab_")->where("1=1")->select();
@ -16,23 +18,27 @@ class MarketPercentageFactory {
} }
} }
public function adminId2GroupID($admin_id){
return M("auth_group_access","sys_")->where("uid = '{$admin_id}'")->getField("group_id");
}
public function returnMarketPercentageArray() { public function returnMarketPercentageArray() {
$map['group_id'] = ['in', '11,12,21']; $map['group_id'] = ['in', $this->groupid];
$marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage");
$all_data = SM("market_altogether", "tab_") $all_data = SM("market_altogether", "tab_")->alias("m")->field("m.*,a.group_id")->join("sys_auth_group_access as a on m.admin_id = a.uid")
->select(); ->select();
$returnArr = []; $returnArr = [];
foreach ($all_data as $key => $value) { foreach ($all_data as $key => $value) {
$level = $value['level']; $level = $value['group_id'];
if (isset($marketPercentage[$level])) { if (isset($marketPercentage[$level])) {
$value['market_percentage'] = $marketPercentage[$level]; $value['market_percentage'] = $marketPercentage[$level];
} }
$market_percentage = json_decode($value['market_percentage'], true); $market_percentage = json_decode($value['market_percentage'], true);
$month = date("m", strtotime($value['pay_time'])); $month = date("m", strtotime($value['pay_time']));
$yes = date("Y", strtotime($value['pay_time'])); $yes = date("Y", strtotime($value['pay_time']));
@ -95,16 +101,18 @@ class MarketPercentageFactory {
//返回待发放 //返回待发放
public function returnWaitMarketPercentageArray() { public function returnWaitMarketPercentageArray() {
$map['group_id'] = ['in', '11,12,21']; $map['group_id'] = ['in', $this->groupid];
$marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage");
$all_data = SM("market_altogether", "tab_") // $all_data = SM("market_altogether", "tab_")
// ->select();
$all_data = SM("market_altogether", "tab_")->alias("m")->field("m.*,a.group_id")->join("sys_auth_group_access as a on m.admin_id = a.uid")
->select(); ->select();
$returnArr = []; $returnArr = [];
foreach ($all_data as $key => $value) { foreach ($all_data as $key => $value) {
$level = $value['level']; $level = $value['group_id'];
if (isset($marketPercentage[$level])) { if (isset($marketPercentage[$level])) {
$value['market_percentage'] = $marketPercentage[$level]; $value['market_percentage'] = $marketPercentage[$level];
} }

Loading…
Cancel
Save