修改财务流水
This commit is contained in:
parent
4c816a972c
commit
79d92394ea
@ -27,6 +27,14 @@ class CommissionDao
|
|||||||
*/
|
*/
|
||||||
public function firstOrderCommission($order, $financeDao)
|
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();
|
$consumption = StoreConsumption::where('status', 1)->where('type', StoreConsumption::TYPE_FIRST_ORDER_COMMISSION)->find();
|
||||||
if (empty($consumption)) {
|
if (empty($consumption)) {
|
||||||
return $financeDao;
|
return $financeDao;
|
||||||
@ -36,14 +44,6 @@ class CommissionDao
|
|||||||
if (!$isFirstOrder) {
|
if (!$isFirstOrder) {
|
||||||
return $financeDao;
|
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');
|
$promotionCode = User::where('uid', $order['uid'])->value('promotion_code');
|
||||||
if (!empty($promotionCode)) {
|
if (!empty($promotionCode)) {
|
||||||
@ -54,7 +54,7 @@ class CommissionDao
|
|||||||
$commission = bcmul($order['pay_price'], 0.03, 2);
|
$commission = bcmul($order['pay_price'], 0.03, 2);
|
||||||
$financeDao->user = $user;
|
$financeDao->user = $user;
|
||||||
$financeDao->order = $order;
|
$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);
|
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
|
||||||
$redPack = bcmul($order['pay_price'], $consumption['config']['red_pack_rate'], 2);
|
$redPack = bcmul($order['pay_price'], $consumption['config']['red_pack_rate'], 2);
|
||||||
if ($redPack > 0) {
|
if ($redPack > 0) {
|
||||||
@ -97,7 +97,7 @@ class CommissionDao
|
|||||||
if ($commission > 0) {
|
if ($commission > 0) {
|
||||||
$financeDao->user = $user;
|
$financeDao->user = $user;
|
||||||
$financeDao->order = $order;
|
$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);
|
$financeDao->platformOut($commission, $financialType);
|
||||||
$result[] = $user;
|
$result[] = $user;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ class CommissionDao
|
|||||||
{
|
{
|
||||||
// 是否已经退过佣金
|
// 是否已经退过佣金
|
||||||
$refunded = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
|
$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();
|
->count();
|
||||||
if ($refunded > 0) {
|
if ($refunded > 0) {
|
||||||
return;
|
return;
|
||||||
@ -167,13 +167,13 @@ class CommissionDao
|
|||||||
// 订单为自提,且佣金大于0,下单的店铺退佣金
|
// 订单为自提,且佣金大于0,下单的店铺退佣金
|
||||||
$financeDao->user = $refundOrder->order->user;
|
$financeDao->user = $refundOrder->order->user;
|
||||||
$financeDao->order = $refundOrder->order;
|
$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);
|
app()->make(MerchantRepository::class)->subLockMoney($refundOrder->order['mer_id'], 'order', $refundOrder->order['order_id'], $commission);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退佣金和红包
|
// 退佣金和红包
|
||||||
$financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
|
$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();
|
->field('user_id uid,user_info nickname')->select()->toArray();
|
||||||
if (empty($financeRecord)) {
|
if (empty($financeRecord)) {
|
||||||
return;
|
return;
|
||||||
|
@ -31,6 +31,14 @@ use think\facade\Db;
|
|||||||
*/
|
*/
|
||||||
class FinancialRecordRepository extends BaseRepository
|
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)
|
public function __construct(FinancialRecordDao $dao)
|
||||||
{
|
{
|
||||||
$this->dao = $dao;
|
$this->dao = $dao;
|
||||||
|
@ -37,14 +37,9 @@ class FinancialRecord extends BaseController
|
|||||||
$merId = $this->request->merId();
|
$merId = $this->request->merId();
|
||||||
if ($merId) {
|
if ($merId) {
|
||||||
$where['mer_id'] = $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',
|
$where['financial_type'] = array_merge($this->repository->commonFinancialType, ['mer_accoubts']);
|
||||||
'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'];
|
|
||||||
} else {
|
} else {
|
||||||
$where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
|
$where['financial_type'] = array_merge($this->repository->commonFinancialType, ['sys_accoubts']);
|
||||||
'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'];
|
|
||||||
}
|
}
|
||||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user