|
|
@ -33,8 +33,9 @@ use app\common\model\store\order\StoreOrderLevel; |
|
|
|
class OrderPartnerJob implements JobInterface |
|
|
|
class OrderPartnerJob implements JobInterface |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
public function fire($job, $data) |
|
|
|
public function fire($job,$data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$job->delete(); |
|
|
|
file_put_contents('/tmp/debug_partner', '开始处理贡献值订单:' . var_export($data, 1), 8); |
|
|
|
file_put_contents('/tmp/debug_partner', '开始处理贡献值订单:' . var_export($data, 1), 8); |
|
|
|
try { |
|
|
|
try { |
|
|
|
//初始化贡献值 |
|
|
|
//初始化贡献值 |
|
|
@ -144,21 +145,21 @@ class OrderPartnerJob implements JobInterface |
|
|
|
//读取消费等级增加生命值 |
|
|
|
//读取消费等级增加生命值 |
|
|
|
$user_hb = 0; |
|
|
|
$user_hb = 0; |
|
|
|
$order_level = StoreOrderLevel::getDB()->order('level asc')->select(); |
|
|
|
$order_level = StoreOrderLevel::getDB()->order('level asc')->select(); |
|
|
|
if(!empty($order_level)){ |
|
|
|
if (!empty($order_level)) { |
|
|
|
foreach($order_level as $k=>$v){ |
|
|
|
foreach ($order_level as $k => $v) { |
|
|
|
if($total_price >= $v->min_price){ |
|
|
|
if ($total_price >= $v->min_price) { |
|
|
|
$user_hb = bcmul($total_price,$v->pay_hp,2); |
|
|
|
$user_hb = bcmul($total_price, $v->pay_hp, 2); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//订单角色贡献值-30% |
|
|
|
//订单角色贡献值-30% |
|
|
|
$user_value = bcmul($total_price, 0.3, 2); |
|
|
|
$user_value = bcmul($total_price, 0.3, 2); |
|
|
|
|
|
|
|
if ($user_value > 0) { |
|
|
|
$user = User::getDB()->where('uid', $data['uid'])->find(); |
|
|
|
$user = User::getDB()->where('uid', $data['uid'])->find(); |
|
|
|
$user->all_value = bcadd($user->all_value, $user_value, 2); |
|
|
|
$user->all_value = bcadd($user->all_value, $user_value, 2); |
|
|
|
//增加生命值 |
|
|
|
//增加生命值 |
|
|
|
if(!empty($user_hb)){ |
|
|
|
if (!empty($user_hb)) { |
|
|
|
$user->hp_value = bcadd($user->hp_value, $user_hb, 2); |
|
|
|
$user->hp_value = bcadd($user->hp_value, $user_hb, 2); |
|
|
|
} |
|
|
|
} |
|
|
|
$user->save(); |
|
|
|
$user->save(); |
|
|
@ -170,6 +171,8 @@ class OrderPartnerJob implements JobInterface |
|
|
|
'memo' => '订单消费贡献值', |
|
|
|
'memo' => '订单消费贡献值', |
|
|
|
'user_id' => $data['uid'], |
|
|
|
'user_id' => $data['uid'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理合作人角色是否包含此商品品牌 |
|
|
|
//处理合作人角色是否包含此商品品牌 |
|
|
|
if (!empty($brand_ids)) { |
|
|
|
if (!empty($brand_ids)) { |
|
|
@ -191,6 +194,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
$role_data = $brand_brand_data[$buv['partner_id']] ?? []; |
|
|
|
$role_data = $brand_brand_data[$buv['partner_id']] ?? []; |
|
|
|
if (!empty($role_data)) { |
|
|
|
if (!empty($role_data)) { |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
|
|
|
|
if ($role_value > 0) { |
|
|
|
if (empty($buv['uid'])) { |
|
|
|
if (empty($buv['uid'])) { |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -207,6 +211,8 @@ class OrderPartnerJob implements JobInterface |
|
|
|
'user_id' => $buv['uid'], |
|
|
|
'user_id' => $buv['uid'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//处理合作人角色是否包含此商品行业 |
|
|
|
//处理合作人角色是否包含此商品行业 |
|
|
@ -229,6 +235,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
$role_data = $trade_trade_data[$tuv['partner_id']] ?? []; |
|
|
|
$role_data = $trade_trade_data[$tuv['partner_id']] ?? []; |
|
|
|
if (!empty($role_data)) { |
|
|
|
if (!empty($role_data)) { |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
|
|
|
|
if ($role_value) { |
|
|
|
if (empty($tuv['uid'])) { |
|
|
|
if (empty($tuv['uid'])) { |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -247,6 +254,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//查询所属区域角色 |
|
|
|
//查询所属区域角色 |
|
|
|
if (!empty($address)) { |
|
|
|
if (!empty($address)) { |
|
|
|
$province_id = $address['province_id'] ?? ''; |
|
|
|
$province_id = $address['province_id'] ?? ''; |
|
|
@ -275,6 +283,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
$role_data = $trade_trade_data[$auv['partner_id']] ?? []; |
|
|
|
$role_data = $trade_trade_data[$auv['partner_id']] ?? []; |
|
|
|
if (!empty($role_data)) { |
|
|
|
if (!empty($role_data)) { |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
|
|
|
|
if ($role_value > 0) { |
|
|
|
if (empty($auv['uid'])) { |
|
|
|
if (empty($auv['uid'])) { |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -291,6 +300,8 @@ class OrderPartnerJob implements JobInterface |
|
|
|
'user_id' => $auv['uid'], |
|
|
|
'user_id' => $auv['uid'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//查询大区角色 |
|
|
|
//查询大区角色 |
|
|
@ -298,16 +309,22 @@ class OrderPartnerJob implements JobInterface |
|
|
|
$region_ids = []; |
|
|
|
$region_ids = []; |
|
|
|
if (!empty($province_id) && !empty($region_list)) { |
|
|
|
if (!empty($province_id) && !empty($region_list)) { |
|
|
|
foreach ($region_list as $rv) { |
|
|
|
foreach ($region_list as $rv) { |
|
|
|
|
|
|
|
|
|
|
|
if (in_array($province_id, $rv['province_ids'])) { |
|
|
|
if (in_array($province_id, $rv['province_ids'])) { |
|
|
|
$region_ids[] = $rv['id']; |
|
|
|
$region_ids[] = $rv['id']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!empty($region_ids)){ |
|
|
|
if (!empty($region_ids)) { |
|
|
|
$region_roles = Partner::getDB() |
|
|
|
$region_roles = Partner::getDB() |
|
|
|
->where('status', 1) |
|
|
|
->where('status', 1) |
|
|
|
->whereNotIn('type', 2) |
|
|
|
->whereNotIn('type', [2]) |
|
|
|
->whereIn('region_id', $region_ids) |
|
|
|
->whereIn('region_id', $region_ids) |
|
|
|
->select()->toArray(); |
|
|
|
->select(); |
|
|
|
|
|
|
|
if (!empty($region_ids)) { |
|
|
|
|
|
|
|
$region_roles = $region_roles->toArray(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$region_roles = []; |
|
|
|
|
|
|
|
} |
|
|
|
$role_ids = array_column($region_roles, 'id'); |
|
|
|
$role_ids = array_column($region_roles, 'id'); |
|
|
|
$regin_trade_data = array_column($region_roles, null, 'id'); |
|
|
|
$regin_trade_data = array_column($region_roles, null, 'id'); |
|
|
|
|
|
|
|
|
|
|
@ -320,6 +337,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
$role_data = $regin_trade_data[$ruv['partner_id']] ?? []; |
|
|
|
$role_data = $regin_trade_data[$ruv['partner_id']] ?? []; |
|
|
|
if (!empty($role_data)) { |
|
|
|
if (!empty($role_data)) { |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
|
|
|
|
if ($role_value > 0) { |
|
|
|
if (empty($ruv['uid'])) { |
|
|
|
if (empty($ruv['uid'])) { |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -336,6 +354,8 @@ class OrderPartnerJob implements JobInterface |
|
|
|
'user_id' => $ruv['uid'], |
|
|
|
'user_id' => $ruv['uid'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -359,6 +379,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
$role_data = $common_trade_data[$cuv['partner_id']] ?? []; |
|
|
|
$role_data = $common_trade_data[$cuv['partner_id']] ?? []; |
|
|
|
if (!empty($role_data)) { |
|
|
|
if (!empty($role_data)) { |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
$role_value = bcmul($total_price, $role_data['ratio'] / 100, 2); |
|
|
|
|
|
|
|
if ($role_value > 0) { |
|
|
|
if (empty($cuv['uid'])) { |
|
|
|
if (empty($cuv['uid'])) { |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
$user = User::getDB()->where('uid', $admin_id)->find();; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -375,6 +396,8 @@ class OrderPartnerJob implements JobInterface |
|
|
|
'user_id' => $cuv['uid'], |
|
|
|
'user_id' => $cuv['uid'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -382,9 +405,9 @@ class OrderPartnerJob implements JobInterface |
|
|
|
ValueContributionLog::getDB()->insertAll($user_log_data); |
|
|
|
ValueContributionLog::getDB()->insertAll($user_log_data); |
|
|
|
echo 'ok'; |
|
|
|
echo 'ok'; |
|
|
|
} catch (\Exception $e) { |
|
|
|
} catch (\Exception $e) { |
|
|
|
Log::info('订单角色贡献值处理失败; error : ' . $e->getMessage()); |
|
|
|
file_put_contents('/tmp/error_partner', '订单角色贡献值处理失败:' . var_export($e->getMessage(), 1), 8); |
|
|
|
} |
|
|
|
} |
|
|
|
$job->delete(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -394,7 +417,7 @@ class OrderPartnerJob implements JobInterface |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//贡献值转增值积分 |
|
|
|
//贡献值转增值积分 |
|
|
|
public function addValue($uid,$num,$user_start) |
|
|
|
public function addValue($uid, $num, $user_start) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//读取用户当前贡献值增长率 |
|
|
|
//读取用户当前贡献值增长率 |
|
|
|
|
|
|
|
|
|
|
|