修改财务流水

This commit is contained in:
luofei 2024-02-01 11:56:57 +08:00
parent 4c816a972c
commit 79d92394ea
3 changed files with 23 additions and 20 deletions

View File

@ -27,6 +27,14 @@ class CommissionDao
*/
public function firstOrderCommission($order, $financeDao)
{
$commission = bcmul($order['pay_price'], 0.01, 2);
if ($commission > 0 && $order['order_type'] == 1) {
// 订单为自提且佣金大于0
$financeDao->user = $order->user;
$financeDao->order = $order;
$financeDao->platformOut($commission, 'commission_to_store');
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
}
$consumption = StoreConsumption::where('status', 1)->where('type', StoreConsumption::TYPE_FIRST_ORDER_COMMISSION)->find();
if (empty($consumption)) {
return $financeDao;
@ -36,14 +44,6 @@ class CommissionDao
if (!$isFirstOrder) {
return $financeDao;
}
$commission = bcmul($order['pay_price'], 0.01, 2);
if ($commission > 0 && $order['order_type'] == 1) {
// 订单为自提且佣金大于0
$financeDao->user = $order->user;
$financeDao->order = $order;
$financeDao->platformOut($commission, 'first_order_commission');
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
}
// 给镇合伙人、村合伙人、小组服务团队、店铺分佣,仅直推
$promotionCode = User::where('uid', $order['uid'])->value('promotion_code');
if (!empty($promotionCode)) {
@ -54,7 +54,7 @@ class CommissionDao
$commission = bcmul($order['pay_price'], 0.03, 2);
$financeDao->user = $user;
$financeDao->order = $order;
$financeDao->platformOut($commission, 'first_order_commission');
$financeDao->platformOut($commission, 'commission_to_promoter');
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
$redPack = bcmul($order['pay_price'], $consumption['config']['red_pack_rate'], 2);
if ($redPack > 0) {
@ -97,7 +97,7 @@ class CommissionDao
if ($commission > 0) {
$financeDao->user = $user;
$financeDao->order = $order;
$financialType = $user['type'] == 3 ? 'order_commission' : 'first_order_commission'; // TODO 配送员的佣金类型需要调整
$financialType = $user['type'] == 4 ? 'commission_to_courier' : 'commission_to_promoter';
$financeDao->platformOut($commission, $financialType);
$result[] = $user;
}
@ -156,7 +156,7 @@ class CommissionDao
{
// 是否已经退过佣金
$refunded = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
->whereIn('financial_type', ['order_commission_refund', 'first_order_commission_refund'])
->whereIn('financial_type', ['commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund'])
->count();
if ($refunded > 0) {
return;
@ -167,13 +167,13 @@ class CommissionDao
// 订单为自提且佣金大于0下单的店铺退佣金
$financeDao->user = $refundOrder->order->user;
$financeDao->order = $refundOrder->order;
$financeDao->platformIn($commission, 'first_order_commission_refund');
$financeDao->platformIn($commission, 'commission_to_store_refund');
app()->make(MerchantRepository::class)->subLockMoney($refundOrder->order['mer_id'], 'order', $refundOrder->order['order_id'], $commission);
}
// 退佣金和红包
$financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
->whereIn('financial_type', ['order_commission', 'first_order_commission'])
->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter'])
->field('user_id uid,user_info nickname')->select()->toArray();
if (empty($financeRecord)) {
return;

View File

@ -31,6 +31,14 @@ use think\facade\Db;
*/
class FinancialRecordRepository extends BaseRepository
{
public $commonFinancialType = [
'order', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund'
,'commission_to_entry_merchant','commission_to_entry_merchant_refund'
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund', 'commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund'
];
public function __construct(FinancialRecordDao $dao)
{
$this->dao = $dao;

View File

@ -37,14 +37,9 @@ class FinancialRecord extends BaseController
$merId = $this->request->merId();
if ($merId) {
$where['mer_id'] = $merId;
$where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund','commission_to_entry_merchant','commission_to_entry_merchant_refund'
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund'];
$where['financial_type'] = array_merge($this->repository->commonFinancialType, ['mer_accoubts']);
} else {
$where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund'
,'commission_to_entry_merchant','commission_to_entry_merchant_refund'
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund'];
$where['financial_type'] = array_merge($this->repository->commonFinancialType, ['sys_accoubts']);
}
return app('json')->success($this->repository->getList($where, $page, $limit));
}