diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 8d098d80..938957ac 100755 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -16,9 +16,7 @@ namespace app\common\repositories\system\merchant; use app\common\dao\system\merchant\FinancialRecordDao; use app\common\repositories\BaseRepository; -use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\user\UserBillRepository; -use app\common\repositories\user\UserRechargeRepository; use think\facade\Cache; use think\facade\Db; @@ -36,7 +34,7 @@ class FinancialRecordRepository extends BaseRepository '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' + ,'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', 'auto_margin', 'auto_margin_refund', 'supply_chain', 'supply_chain_refund', 'platform_consumption', 'platform_consumption_refund' ]; public function __construct(FinancialRecordDao $dao) @@ -124,41 +122,39 @@ class FinancialRecordRepository extends BaseRepository $count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'order_presell', 'presell'])->sum('number'); //退款支出金额 $refund_order = $this->dao->search($where)->where('financial_type', 'refund_order')->sum('number'); + $platformProfit = bcsub($count, $refund_order, 2); //佣金支出金额 $brokerage_ = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number'); $_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_two', 'refund_brokerage_one'])->sum('number'); $brokerage = bcsub($brokerage_, $_brokerage, 2); - - //入口店铺佣金 - $entry_merchant=$this->dao->search($where)->where('financial_type', 'commission_to_entry_merchant')->sum('number'); - $entry_merchant_refund=$this->dao->search($where)->where('financial_type', 'commission_to_entry_merchant_refund')->sum('number'); - //云仓库佣金 - $cloud_warehouse=$this->dao->search($where)->where('financial_type', 'commission_to_cloud_warehouse')->sum('number'); - $cloud_warehouse_refund=$this->dao->search($where)->where('financial_type', 'commission_to_cloud_warehouse_refund')->sum('number'); - //服务团队佣金 - $service_team=$this->dao->search($where)->where('financial_type', 'commission_to_service_team')->sum('number'); - $service_team_refund=$this->dao->search($where)->where('financial_type', 'commission_to_service_team_refund')->sum('number'); - //村团队佣金 - $village=$this->dao->search($where)->where('financial_type', 'commission_to_village')->sum('number'); - $village_refund=$this->dao->search($where)->where('financial_type', 'commission_to_village_refund')->sum('number'); - //镇佣金 - $town=$this->dao->search($where)->where('financial_type', 'commission_to_town')->sum('number'); - $town_refund=$this->dao->search($where)->where('financial_type', 'commission_to_town_refund')->sum('number'); + $platformProfit = bcsub($platformProfit, $brokerage, 2); + // 保证金 + $margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number'); + $marginRefund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number'); + $platformProfit = bcadd($platformProfit, $margin, 2); + $platformProfit = bcsub($platformProfit, $marginRefund, 2); //直推首单佣金 $promoter = $this->dao->search($where)->where('financial_type', 'commission_to_promoter')->sum('number'); $promoterRefund = $this->dao->search($where)->where('financial_type', 'commission_to_promoter_refund')->sum('number'); + $platformProfit = bcsub($platformProfit, $promoter, 2); + $platformProfit = bcadd($platformProfit, $promoterRefund, 2); //配送员佣金 $courier = $this->dao->search($where)->where('financial_type', 'commission_to_courier')->sum('number'); $courierRefund = $this->dao->search($where)->where('financial_type', 'commission_to_courier_refund')->sum('number'); + $platformProfit = bcsub($platformProfit, $courier, 2); + $platformProfit = bcadd($platformProfit, $courierRefund, 2); //提货店铺佣金 $store = $this->dao->search($where)->where('financial_type', 'commission_to_store')->sum('number'); $storeRefund = $this->dao->search($where)->where('financial_type', 'commission_to_store_refund')->sum('number'); - //平台手续费 - $charge_ = $this->dao->search($where)->where('financial_type', 'in', ['order_charge', 'presell_charge'])->sum('number'); - $_charge = $this->dao->search($where)->where('financial_type', 'refund_charge')->sum('number'); - $charge = bcsub($charge_, $_charge, 2); + $platformProfit = bcsub($platformProfit, $store, 2); + $platformProfit = bcadd($platformProfit, $storeRefund, 2); //优惠券费用 ,'order_platform_coupon','order_svip_coupon' $coupon = $this->dao->search($where)->where('financial_type', 'in', ['order_platform_coupon', 'order_svip_coupon'])->sum('number'); + // 消费金 + $consumption = $this->dao->search($where)->where('financial_type', 'platform_consumption')->sum('number'); + $consumptionRefund = $this->dao->search($where)->where('financial_type', 'platform_consumption_refund')->sum('number'); + $platformProfit = bcsub($platformProfit, $consumption, 2); + $platformProfit = bcadd($platformProfit, $consumptionRefund, 2); //充值金额 $bill_where = [ 'status' => 1, @@ -196,12 +192,6 @@ class FinancialRecordRepository extends BaseRepository 'field' => '元', 'name' => '佣金支出金额' ], - [ - 'className' => 'el-icon-s-cooperation', - 'count' => $charge, - 'field' => '元', - 'name' => '平台手续费' - ], [ 'className' => 'el-icon-s-finance', 'count' => $bill, @@ -225,51 +215,42 @@ class FinancialRecordRepository extends BaseRepository 'count' => $coupon, 'field' => '元', 'name' => '优惠券金额' - ],[ + ], + [ 'className' => 'el-icon-s-order', - 'count' => bcsub($entry_merchant,$entry_merchant_refund,2), + 'count' => bcsub($margin, $marginRefund, 2), 'field' => '元', - 'name' => '入口商户佣金' - ],[ - 'className' => 'el-icon-s-order', - 'count' => bcsub($cloud_warehouse,$cloud_warehouse_refund,2), - 'field' => '元', - 'name' => '云仓库佣金' - ],[ - 'className' => 'el-icon-s-order', - 'count' => bcsub($service_team,$service_team_refund,2), - 'field' => '元', - 'name' => '小组服务佣金' - ],[ - 'className' => 'el-icon-s-order', - 'count' => bcsub($village,$village_refund,2), - 'field' => '元', - 'name' => '村佣金' - ],[ - 'className' => 'el-icon-s-order', - 'count' => bcsub($town,$town_refund,2), - 'field' => '元', - 'name' => '镇佣金' - ],[ + 'name' => '店铺保证金' + ], + [ 'className' => 'el-icon-s-order', 'count' => bcsub($promoter, $promoterRefund, 2), 'field' => '元', 'name' => '直推首单佣金' - ],[ + ], + [ 'className' => 'el-icon-s-order', 'count' => bcsub($courier, $courierRefund, 2), 'field' => '元', 'name' => '配送员佣金' - ],[ + ], + [ 'className' => 'el-icon-s-order', 'count' => bcsub($store, $storeRefund, 2), 'field' => '元', 'name' => '提货店铺佣金' - ],[ + ], + [ 'className' => 'el-icon-s-order', - 'count' =>bcsub($charge, bcadd(bcadd(bcadd($entry_merchant, $cloud_warehouse, 2), $service_team, 2), $village, 2), 2), + 'count' => bcsub($consumption, $consumptionRefund, 2), 'field' => '元', - 'name' => '平台剩余手续费' + 'name' => '平台红包(包含通用和抵扣)' + ], + [ + 'className' => 'el-icon-s-order', + 'count' => $platformProfit, + 'field' => '元', + 'name' => '平台结余' ], ]; return compact('stat'); diff --git a/app/controller/api/server/Store.php b/app/controller/api/server/Store.php new file mode 100644 index 00000000..45dc89df --- /dev/null +++ b/app/controller/api/server/Store.php @@ -0,0 +1,31 @@ +merId = $this->request->route('merId'); + } + + /** + * 生成二维码 + */ + public function qrcode() + { + $common = app()->make(Common::class); + $siteUrl = systemConfig('site_url'); + $data = $common->Qrcode(['code' => $siteUrl . 'download/index.html?code=mer_' . $this->merId, 'id' => $this->merId]); + return app('json')->success(['url' => $data]); + } + +} diff --git a/route/api.php b/route/api.php index 0c299b63..777d1e55 100755 --- a/route/api.php +++ b/route/api.php @@ -299,6 +299,7 @@ Route::group('api/', function () { //客服商品管理 Route::group('server/:merId', function () { + Route::get('qrcode', 'Store/qrcode'); //商品 Route::post('product/create', 'StoreProduct/create'); Route::post('product/update/:id', 'StoreProduct/update');