生命值增加

main
limu 11 months ago
parent d5e50d0418
commit 8a6ea46752
  1. 24
      crmeb/jobs/OrderPartnerJob.php

@ -28,6 +28,7 @@ use app\common\model\store\product\Spu;
use app\common\model\user\ValueContributionLog; use app\common\model\user\ValueContributionLog;
use app\common\model\store\order\StoreOrderContribute; use app\common\model\store\order\StoreOrderContribute;
use app\common\repositories\user\UserAddressRepository; use app\common\repositories\user\UserAddressRepository;
use app\common\model\store\order\StoreOrderLevel;
class OrderPartnerJob implements JobInterface class OrderPartnerJob implements JobInterface
{ {
@ -41,6 +42,7 @@ class OrderPartnerJob implements JobInterface
$bao_flowing = $mian_flowing = $ping_flowing = 0; $bao_flowing = $mian_flowing = $ping_flowing = 0;
$brand_ids = $trade_ids = $user_log_data = []; $brand_ids = $trade_ids = $user_log_data = [];
$admin_id = config('partner.gongxian_admin_id') ?? ''; $admin_id = config('partner.gongxian_admin_id') ?? '';
//查询商品类型 -报单区 100% 免单区66.7% 平价区66.7% //查询商品类型 -报单区 100% 免单区66.7% 平价区66.7%
$order_product = StoreOrderProduct::getDB() $order_product = StoreOrderProduct::getDB()
->where('order_id', $data['order_id']) ->where('order_id', $data['order_id'])
@ -95,6 +97,7 @@ class OrderPartnerJob implements JobInterface
if ($has_contribute == false) { if ($has_contribute == false) {
throw new Exception('订单没有指定三种类型商品,不计入贡献值统计'); throw new Exception('订单没有指定三种类型商品,不计入贡献值统计');
} }
//读取品牌所属分类 //读取品牌所属分类
if (!empty($brand_ids)) { if (!empty($brand_ids)) {
$brand_ids = array_unique($brand_ids); $brand_ids = array_unique($brand_ids);
@ -137,11 +140,26 @@ class OrderPartnerJob implements JobInterface
'ping_liushui' => $ping_flowing, 'ping_liushui' => $ping_flowing,
]; ];
StoreOrderContribute::getDB()->insert($contribute_insert); StoreOrderContribute::getDB()->insert($contribute_insert);
//读取消费等级增加生命值
$user_hb = 0;
$order_level = StoreOrderLevel::getDB()->order('level asc')->select();
if(!empty($order_level)){
foreach($order_level as $k=>$v){
if($total_price >= $v->min_price){
$user_hb = bcmul($total_price,$v->pay_hp,2);
}
}
}
//订单角色贡献值-30% //订单角色贡献值-30%
$user_value = bcmul($total_price, 0.3, 2); $user_value = bcmul($total_price, 0.3, 2);
$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)){
$user->hp_value = bcadd($user->hp_value, $user_hb, 2);
}
$user->save(); $user->save();
$user_log_data[] = [ $user_log_data[] = [
'type' => 6, 'type' => 6,
@ -374,4 +392,10 @@ class OrderPartnerJob implements JobInterface
{ {
// TODO: Implement failed() method. // TODO: Implement failed() method.
} }
//贡献值转增值积分
public function addValue($uid,$num)
{
}
} }

Loading…
Cancel
Save