parent
3d83f49ea7
commit
c82b023545
|
|
@ -123,17 +123,23 @@ class UserBillDao extends BaseDao
|
|||
foreach($lst as $bill){
|
||||
$refundPrice = bcadd($refundPrice,$bill['number'],2);
|
||||
}
|
||||
// 招商佣金&推广员佣金
|
||||
|
||||
return $refundPrice;
|
||||
/* // 招商佣金&推广员佣金
|
||||
$commissionList = UserBill::getDB()->where('category', 'brokerage')
|
||||
->whereIn('type', ['commission_merchants','commission_promoter'])
|
||||
->where('uid', $uid)
|
||||
->where('pm', 1)
|
||||
->where('status', 0)
|
||||
->field('link_id,number')
|
||||
->select()
|
||||
->toArray();
|
||||
$commissionRefundPrice = 0;
|
||||
if (count($lst)) {
|
||||
$commissionRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
|
||||
if (count($commissionList)) {
|
||||
$commissionRefundPrice = -1 * UserBill::getDB()
|
||||
->whereIn('link_id', array_column($commissionList, 'link_id'))
|
||||
->where('uid', $uid)
|
||||
->where('pm', 0)
|
||||
->where('category', 'brokerage')
|
||||
->whereIn('type', ['commission_merchants', 'commission_promoter'])
|
||||
->sum('number');
|
||||
|
|
@ -146,13 +152,16 @@ class UserBillDao extends BaseDao
|
|||
->where('category', 'brokerage')
|
||||
->whereIn('type', ['commission_partner'])
|
||||
->where('uid', $uid)
|
||||
->where('pm', 1)
|
||||
->where('status', 0)
|
||||
->field('link_id,number')
|
||||
->select()
|
||||
->toArray();
|
||||
$commissionPartnerRefundPrice = 0;
|
||||
if (count($lst)) {
|
||||
$commissionPartnerRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))
|
||||
if (count($commissionPartnerList)) {
|
||||
$commissionPartnerRefundPrice = -1 * UserBill::getDB()
|
||||
->whereIn('link_id', array_column($commissionPartnerList, 'link_id'))
|
||||
->where('pm', 0)
|
||||
->where('uid', $uid)
|
||||
->where('category', 'brokerage')
|
||||
->whereIn('type', ['commission_partner'])
|
||||
|
|
@ -160,10 +169,10 @@ class UserBillDao extends BaseDao
|
|||
}
|
||||
foreach ($commissionPartnerList as $billThree) {
|
||||
$commissionPartnerRefundPrice = bcadd($commissionPartnerRefundPrice, $billThree['number'], 2);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
return (float)sprintf("%.2f",(float)$refundPrice + (float)$commissionRefundPrice + (float)$commissionPartnerList);
|
||||
// return (float)sprintf("%.2f",(float)$refundPrice + (float)$commissionRefundPrice + (float)$commissionPartnerList);
|
||||
}
|
||||
|
||||
public function lockIntegral($uid = null, $order_id = null)
|
||||
|
|
|
|||
|
|
@ -230,9 +230,16 @@ class User extends BaseModel
|
|||
return app()->make(UserBillRepository::class)->totalBrokerage($this->uid) ?: 0;
|
||||
}
|
||||
|
||||
public function getTotalBrokeragePriceAttr()
|
||||
{
|
||||
return bcadd($this->lock_brokerage, $this->brokerage_price, 2);
|
||||
public function getBrokeragePriceAttr($value){
|
||||
// 添加:合伙人佣金、招商佣金、推广佣金
|
||||
$PlatformCommissionMoney = app()->make(UserBillRepository::class)->getPlatformCommissionMoney($this->uid);
|
||||
|
||||
// debug([$value,$PlatformCommissionMoney]);
|
||||
return (float)sprintf("%.2f",$value + $PlatformCommissionMoney);
|
||||
}
|
||||
|
||||
public function getTotalBrokeragePriceAttr(){
|
||||
return (float)bcadd($this->lock_brokerage, $this->brokerage_price, 2);
|
||||
}
|
||||
|
||||
public function getTotalIntegralAttr()
|
||||
|
|
|
|||
|
|
@ -269,7 +269,11 @@ class PointsOrderCreateRepository
|
|||
if (!$orderInfo['address']['province_id']) throw new ValidateException('请完善收货地址信息');
|
||||
if (!$orderInfo['order_delivery_status']) throw new ValidateException('部分商品配送方式不一致,请单独下单');
|
||||
if ($orderInfo['order_total_price'] > 1000000) throw new ValidateException('支付金额超出最大限制');
|
||||
if ($orderInfo['order_total_integral'] > $user->integral) throw new ValidateException('积分不足');
|
||||
// if ($orderInfo['order_total_integral'] > $user->integral) throw new ValidateException('积分不足');
|
||||
|
||||
$hold_legumes_integral = app()->make(LegumesLogRepository::class)->getHoldLegumesIntegral((int)$user->uid);
|
||||
if ($orderInfo['order_total_integral'] > $hold_legumes_integral) throw new ValidateException('积分不足');
|
||||
|
||||
$merchantCartList = $orderInfo['order'];
|
||||
$address =$orderInfo['address'];
|
||||
$user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : '';
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ class PartnerSettlementCycleRepository extends BaseRepository{
|
|||
if($this->set['commission_partner_cycle'] == 1) [$this->startTime,$this->endTime] = getTimeStamp('last_week');// 周
|
||||
else if($this->set['commission_partner_cycle'] == 2) [$this->startTime,$this->endTime] = getTimeStamp('last_month');// 月
|
||||
else [$this->startTime,$this->endTime] = getTimeStamp('yesterday');// 天
|
||||
|
||||
// [$this->startTime,$this->endTime] = getTimeStamp('today');// 测试使用
|
||||
// 判断:是否允许执行
|
||||
$this->settlementIsRun();
|
||||
// 佣金分红计算并且记录
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace app\common\repositories\user;
|
|||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\dao\user\UserBillDao;
|
||||
use app\common\model\user\UserBill;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use crmeb\jobs\SendSmsJob;
|
||||
|
|
@ -264,6 +265,33 @@ class UserBillRepository extends BaseRepository
|
|||
],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Common: 获取用户实际获得的可用合伙人佣金、推广佣金、招商佣金(已解冻)
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/04 18:00
|
||||
* @param $uid
|
||||
* @return float
|
||||
*/
|
||||
public function getPlatformCommissionMoney($uid){
|
||||
// 获得佣金
|
||||
$increaseMoney = (float)UserBill::getDB()->where('category', 'brokerage')
|
||||
->whereIn('type', ['commission_merchants','commission_promoter', 'commission_partner'])
|
||||
->where('uid', $uid)
|
||||
->where('pm', 1)
|
||||
->where('status', 1)
|
||||
->field('link_id,number')
|
||||
->sum('number');
|
||||
// 退款减少佣金
|
||||
$reduceMoney = (float)UserBill::getDB()->where('category', 'brokerage')
|
||||
->whereIn('type', ['commission_merchants','commission_promoter', 'commission_partner'])
|
||||
->where('uid', $uid)
|
||||
->where('pm', 0)
|
||||
->where('status', 1)
|
||||
->field('link_id,number')
|
||||
->sum('number');
|
||||
|
||||
// 实际获得佣金
|
||||
return (float)sprintf("%.2f", $increaseMoney - $reduceMoney);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,11 @@ class UserExtractRepository extends BaseRepository
|
|||
if(!$openid) throw new ValidateException('openID获取失败,请确认是微信用户');
|
||||
}
|
||||
}
|
||||
$brokerage_price = bcsub($user['brokerage_price'],$data['extract_price'],2);
|
||||
// 由于 佣金包含平台抽成相关佣金 需要减去相关佣金,然后计算。否则会出现问题
|
||||
$PlatformCommissionMoney = app()->make(UserBillRepository::class)->getPlatformCommissionMoney($user['uid']);
|
||||
$brokeragePrice = bcsub($user['brokerage_price'],$PlatformCommissionMoney,2);
|
||||
$brokerage_price = bcsub($brokeragePrice,$data['extract_price'],2);
|
||||
// debug($brokerage_price);
|
||||
$user->brokerage_price = $brokerage_price;
|
||||
$user->save();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue