commit
43a87aac81
app
common
model/system/merchant
repositories
store/order
system/merchant
controller
crmeb/services
route/admin
@ -50,4 +50,26 @@ class FinancialRecord extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->hasOne(StoreRefundOrder::class,'refund_order_sn','order_sn');
|
return $this->hasOne(StoreRefundOrder::class,'refund_order_sn','order_sn');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取备注
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMark()
|
||||||
|
{
|
||||||
|
switch ($this->financial_type) {
|
||||||
|
case 'commission_to_platform':
|
||||||
|
return '平台手续费:' . $this->number;
|
||||||
|
case 'platform_consumption':
|
||||||
|
return '使用平台优惠:' . $this->number;
|
||||||
|
case 'auto_margin':
|
||||||
|
return '保证金:' . $this->number;
|
||||||
|
case 'commission_to_promoter':
|
||||||
|
$nickname = User::where('uid', $this->user_id)->value('nickname');
|
||||||
|
return "“{$nickname}”获得推广佣金:" . $this->number;
|
||||||
|
default:
|
||||||
|
return '商户入账:' . $this->number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
$platformCommission = bcmul($orderValidAmount, (string)$commission_rate, 2);
|
$platformCommission = bcmul($orderValidAmount, (string)$commission_rate, 2);
|
||||||
if ($commission_rate > 0 && $platformCommission > 0) {
|
if ($commission_rate > 0 && $platformCommission > 0) {
|
||||||
$orderValidAmount = bcsub($orderValidAmount, $platformCommission, 2);
|
$orderValidAmount = bcsub($orderValidAmount, $platformCommission, 2);
|
||||||
if ($promoterCommission > 0) {
|
if ($promoterCommission > 0 && !empty($promoter)) {
|
||||||
$platformCommission = bcsub($platformCommission, $promoterCommission, 2);
|
$platformCommission = bcsub($platformCommission, $promoterCommission, 2);
|
||||||
}
|
}
|
||||||
$financeDao->platformIn($platformCommission, 'commission_to_platform', $order['mer_id']);
|
$financeDao->platformIn($platformCommission, 'commission_to_platform', $order['mer_id']);
|
||||||
@ -1344,6 +1344,7 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
if ($order['is_virtual'] && $data['delivery_type'] != 3)
|
if ($order['is_virtual'] && $data['delivery_type'] != 3)
|
||||||
throw new ValidateException('虚拟商品只能虚拟发货');
|
throw new ValidateException('虚拟商品只能虚拟发货');
|
||||||
//订单记录
|
//订单记录
|
||||||
|
/** @var StoreOrderStatusRepository $statusRepository */
|
||||||
$statusRepository = app()->make(StoreOrderStatusRepository::class);
|
$statusRepository = app()->make(StoreOrderStatusRepository::class);
|
||||||
switch ($data['delivery_type']) {
|
switch ($data['delivery_type']) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -1385,6 +1386,8 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
'change_message' => $change_message,
|
'change_message' => $change_message,
|
||||||
'change_type' => $change_type,
|
'change_type' => $change_type,
|
||||||
];
|
];
|
||||||
|
$statusRepository->adminId = $order['mer_id'];
|
||||||
|
$statusRepository->adminNickname = $order->merchant['nickname'];
|
||||||
if ($service_id) {
|
if ($service_id) {
|
||||||
$statusRepository->createServiceLog($service_id, $orderStatus);
|
$statusRepository->createServiceLog($service_id, $orderStatus);
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,6 +100,8 @@ class StoreOrderStatusRepository extends BaseRepository
|
|||||||
const ORDER_DELIVERY_CITY_REFUND = 'delivery_5_10';
|
const ORDER_DELIVERY_CITY_REFUND = 'delivery_5_10';
|
||||||
const ORDER_DELIVERY_CITY_REFUNDING = 'delivery_5_9';
|
const ORDER_DELIVERY_CITY_REFUNDING = 'delivery_5_9';
|
||||||
|
|
||||||
|
public $adminId;
|
||||||
|
public $adminNickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StoreOrderStatusRepository constructor.
|
* StoreOrderStatusRepository constructor.
|
||||||
@ -134,9 +136,15 @@ class StoreOrderStatusRepository extends BaseRepository
|
|||||||
public function createAdminLog(array $data)
|
public function createAdminLog(array $data)
|
||||||
{
|
{
|
||||||
$request = request();
|
$request = request();
|
||||||
$data['user_type'] = $request->userType();
|
if ($request->hasMacro('userType')) {
|
||||||
$data['uid'] = $data['user_type'] == 1 ? $request->uid() : $request->adminId();
|
$data['user_type'] = $request->userType();
|
||||||
$data['nickname'] = $data['user_type'] == 1 ? $request->userInfo()->real_name : $request->adminInfo()->real_name;
|
$data['uid'] = $data['user_type'] == 1 ? $request->uid() : $request->adminId();
|
||||||
|
$data['nickname'] = $data['user_type'] == 1 ? $request->userInfo()->real_name : $request->adminInfo()->real_name;
|
||||||
|
} else {
|
||||||
|
$data['user_type'] = 3;
|
||||||
|
$data['uid'] = $this->adminId;
|
||||||
|
$data['nickname'] = $this->adminNickname;
|
||||||
|
}
|
||||||
return $this->dao->create($data);
|
return $this->dao->create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,8 @@ class MerchantIntentionRepository extends BaseRepository
|
|||||||
'is_company'=>$intention['is_company'],
|
'is_company'=>$intention['is_company'],
|
||||||
'business_status'=>2,
|
'business_status'=>2,
|
||||||
'mer_settlement_agree_status'=>1,
|
'mer_settlement_agree_status'=>1,
|
||||||
'commission_rate'=>$commissionRate,
|
'commission_rate'=>$commissionRate * 100,
|
||||||
|
'financial_bank'=>$intention['financial_bank'],
|
||||||
];
|
];
|
||||||
if($margin['type_code']=='PersonalStore'){
|
if($margin['type_code']=='PersonalStore'){
|
||||||
$merData['mer_address']='集体地址';
|
$merData['mer_address']='集体地址';
|
||||||
|
@ -161,4 +161,28 @@ class FinancialRecord extends BaseController
|
|||||||
return app('json')->success($data);
|
return app('json')->success($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 导出文件
|
||||||
|
* @param $type
|
||||||
|
* @author Qinii
|
||||||
|
* @day 3/25/21
|
||||||
|
*/
|
||||||
|
public function exportDetail2($type)
|
||||||
|
{
|
||||||
|
[$page, $limit] = $this->getPage();
|
||||||
|
$date = $this->request->param('date');
|
||||||
|
$where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
|
||||||
|
$where['type'] = $type;
|
||||||
|
$where['is_mer'] = $this->request->merId() ?? 0 ;
|
||||||
|
try {
|
||||||
|
$merchant = $this->request->merchant();
|
||||||
|
}catch (\Exception $e){
|
||||||
|
$merchant = [];
|
||||||
|
}
|
||||||
|
/** @var ExcelService $make */
|
||||||
|
$make = app()->make(ExcelService::class);
|
||||||
|
$data = $make->exportFinancial2($where,$page,$limit,$merchant);
|
||||||
|
return app('json')->success($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,12 @@ class MerchantIntention extends BaseController
|
|||||||
'street_id',
|
'street_id',
|
||||||
'village_id',
|
'village_id',
|
||||||
'is_nmsc',
|
'is_nmsc',
|
||||||
'is_company'
|
'is_company',
|
||||||
|
'financial_bank'
|
||||||
]);
|
]);
|
||||||
|
if (!empty($data['financial_bank'])) {
|
||||||
|
$data['financial_bank'] = json_encode($data['financial_bank']);
|
||||||
|
}
|
||||||
if (!systemConfig('mer_intention_open')) {
|
if (!systemConfig('mer_intention_open')) {
|
||||||
return app('json')->fail('未开启商户入驻');
|
return app('json')->fail('未开启商户入驻');
|
||||||
}
|
}
|
||||||
@ -344,8 +348,12 @@ class MerchantIntention extends BaseController
|
|||||||
'bank_back',
|
'bank_back',
|
||||||
'cardno_front',
|
'cardno_front',
|
||||||
'cardno_back',
|
'cardno_back',
|
||||||
|
'financial_bank',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!empty($data['financial_bank'])) {
|
||||||
|
$data['financial_bank'] = json_encode($data['financial_bank']);
|
||||||
|
}
|
||||||
app()->make(MerchantIntentionValidate::class)->check($data);
|
app()->make(MerchantIntentionValidate::class)->check($data);
|
||||||
$check = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['code'], 'intention');
|
$check = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['code'], 'intention');
|
||||||
$data['mer_type_id'] = (int)$data['mer_type_id'];
|
$data['mer_type_id'] = (int)$data['mer_type_id'];
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace crmeb\services;
|
namespace crmeb\services;
|
||||||
|
|
||||||
|
use app\common\model\system\merchant\FinancialRecord;
|
||||||
use app\common\repositories\store\order\StoreImportDeliveryRepository;
|
use app\common\repositories\store\order\StoreImportDeliveryRepository;
|
||||||
use app\common\repositories\store\order\StoreOrderProfitsharingRepository;
|
use app\common\repositories\store\order\StoreOrderProfitsharingRepository;
|
||||||
use app\common\repositories\store\order\StoreOrderRepository;
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
@ -313,7 +314,7 @@ class ExcelService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 平台/商户 导出日月账单信息
|
* 平台/商户 导出日月账单信息
|
||||||
* @param array $where
|
* @param array $where
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @author Qinii
|
* @author Qinii
|
||||||
@ -439,6 +440,95 @@ class ExcelService
|
|||||||
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台导出日月账单信息
|
||||||
|
* @param array $where
|
||||||
|
* @param int $page
|
||||||
|
* @param int $limit
|
||||||
|
* @param $merchant
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function exportFinancial2(array $where, int $page, int $limit, $merchant = [])
|
||||||
|
{
|
||||||
|
$financialType = FinancialRecordRepository::TYPE_CN_MAP;
|
||||||
|
$date_ = $where['date'];
|
||||||
|
unset($where['date']);
|
||||||
|
/** @var FinancialRecordRepository $make */
|
||||||
|
$make = app()->make(FinancialRecordRepository::class);
|
||||||
|
$query = $make->search($where)->with(['orderInfo', 'refundOrder', 'merchant.merchantCategory']);
|
||||||
|
if ($where['type'] == 1) {
|
||||||
|
$title_ = '日账单';
|
||||||
|
$start_date = $date_ . ' 00:00:00';
|
||||||
|
$end_date = $date_ . ' 23:59:59';
|
||||||
|
$query->whereDay('create_time', $date_);
|
||||||
|
} else {
|
||||||
|
$title_ = '月账单';
|
||||||
|
$start_date = (date('Y-m-01', strtotime($date_)));
|
||||||
|
$end_date = date('Y-m-d', strtotime("$start_date +1 month -1 day"));
|
||||||
|
$query->whereMonth('create_time', $date_);
|
||||||
|
}
|
||||||
|
$query->where('financial_type', 'order');
|
||||||
|
$income = $make->countIncome($where['type'], $where, $date_, $merchant);
|
||||||
|
$expend = $make->countExpend($where['type'], $where, $date_, $merchant);
|
||||||
|
$charge = bcsub($income['number'], $expend['number'], 2);
|
||||||
|
$filename = $title_ . '(' . $date_ . ')' . time();
|
||||||
|
$export = [];
|
||||||
|
$limit = 20;
|
||||||
|
$count = $query->count();
|
||||||
|
$header = ['商户类别', '商户分类', '商户名称', '总订单号', '订单编号', '交易流水号', '交易时间', '对方信息', '交易类型', '收支金额', '备注'];
|
||||||
|
$list = $query->page($page, $limit)->order('create_time DESC')->select();
|
||||||
|
foreach ($list as $financialRecord) {
|
||||||
|
$otherRecords = FinancialRecord::where('order_id', $financialRecord['order_id'])
|
||||||
|
->whereIn('financial_type', ['commission_to_platform', 'platform_consumption', 'auto_margin', 'commission_to_promoter', 'merchant_order'])
|
||||||
|
->field('financial_type,number')
|
||||||
|
->select();
|
||||||
|
$mark = [];
|
||||||
|
foreach ($otherRecords as $otherRecord) {
|
||||||
|
/** @var FinancialRecord $otherRecord */
|
||||||
|
if (!empty($otherRecord->getMark())) {
|
||||||
|
$mark[] = $otherRecord->getMark();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($financialRecord['merchant']) {
|
||||||
|
$exportItem = [
|
||||||
|
$financialRecord['merchant']['is_trader'] ? '自营' : '非自营',
|
||||||
|
$financialRecord['merchant']['merchantCategory']['category_name'] ?? '平台',
|
||||||
|
$financialRecord['merchant']['mer_name'] ?? '平台',
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$exportItem = [
|
||||||
|
'平台',
|
||||||
|
'平台',
|
||||||
|
'平台',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$exportItem[] = ['groupOrder']['group_order_sn'] ?? '无数据';
|
||||||
|
$exportItem[] = $financialRecord['order_sn'];
|
||||||
|
$exportItem[] = $financialRecord['financial_record_sn'];
|
||||||
|
$exportItem[] = $financialRecord['create_time'];
|
||||||
|
$exportItem[] = $financialRecord['user_info'];
|
||||||
|
$exportItem[] = $financialType[$financialRecord['financial_type']];
|
||||||
|
$exportItem[] = $financialRecord['number'];
|
||||||
|
$exportItem[] = implode(',', $mark);
|
||||||
|
$export[] = $exportItem;
|
||||||
|
}
|
||||||
|
$foot = [
|
||||||
|
'合计:平台应入账手续费 ' . $charge,
|
||||||
|
'收入合计: ' . '订单支付' . $income['count'] . '笔,' . '实际支付金额共:' . $income['number'] . '元;',
|
||||||
|
'支出合计: ' . '佣金支出' . $expend['count_brokerage'] . '笔,支出金额:' . $expend['number_brokerage'] . '元;商户入账支出' . $expend['count_order'] . '笔,支出金额:' . $expend['number_order'] . '元;退款手续费' . $expend['count_charge'] . '笔,支出金额' . $expend['number_charge'] . '元;合计支出' . $expend['number'],
|
||||||
|
];
|
||||||
|
$title = [
|
||||||
|
$title_,
|
||||||
|
$mer_name ?? '平台',
|
||||||
|
'结算账期:【' . $start_date . '】至【' . $end_date . '】',
|
||||||
|
'生成时间:' . date('Y-m-d H:i:s', time())
|
||||||
|
];
|
||||||
|
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 退款单导出
|
* TODO 退款单导出
|
||||||
* @param array $where
|
* @param array $where
|
||||||
|
@ -196,6 +196,9 @@ Route::group(function () {
|
|||||||
Route::get('detail_export/:type', '/exportDetail')->name('systemFinancialRecordDetailExport')->option([
|
Route::get('detail_export/:type', '/exportDetail')->name('systemFinancialRecordDetailExport')->option([
|
||||||
'_alias' => '导出',
|
'_alias' => '导出',
|
||||||
]);
|
]);
|
||||||
|
Route::get('detail_export2/:type', '/exportDetail2')->name('systemFinancialRecordDetailExport2')->option([
|
||||||
|
'_alias' => '导出',
|
||||||
|
]);
|
||||||
})->prefix('admin.system.merchant.FinancialRecord')->option([
|
})->prefix('admin.system.merchant.FinancialRecord')->option([
|
||||||
'_path' => '/accounts/statement',
|
'_path' => '/accounts/statement',
|
||||||
'_auth' => true,
|
'_auth' => true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user