Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
This commit is contained in:
commit
4362d43795
@ -4,7 +4,10 @@ namespace app\admin\controller\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_finance_flow\StoreFinanceFlowDayLists;
|
||||
use app\admin\lists\store_finance_flow\StoreFinanceFlowLists;
|
||||
use app\admin\lists\store_finance_flow\StoreFinanceFlowMonthLists;
|
||||
use app\admin\lists\store_finance_flow\StoreFinanceFlowWeekLists;
|
||||
use app\admin\logic\store_finance_flow\StoreFinanceFlowLogic;
|
||||
use app\admin\validate\store_finance_flow\StoreFinanceFlowValidate;
|
||||
|
||||
@ -28,6 +31,36 @@ class StoreFinanceFlowController extends BaseAdminController
|
||||
{
|
||||
return $this->dataLists(new StoreFinanceFlowLists());
|
||||
}
|
||||
/**
|
||||
* @notes 获取日账单列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function day_bill_lists()
|
||||
{
|
||||
return $this->dataLists(new StoreFinanceFlowDayLists());
|
||||
}
|
||||
/**
|
||||
* @notes 获取周账单列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function week_bill_lists()
|
||||
{
|
||||
return $this->dataLists(new StoreFinanceFlowWeekLists());
|
||||
}
|
||||
/**
|
||||
* @notes 获取月账单列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function month_bill_lists()
|
||||
{
|
||||
return $this->dataLists(new StoreFinanceFlowMonthLists());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -261,7 +261,7 @@ class SystemStoreStatisticsController extends BaseAdminController
|
||||
[
|
||||
"id"=> 46,
|
||||
"name"=> "王多鱼的商超",
|
||||
"image"=> "https=>//multi-store.crmeb.net/uploads/attach/2024/05/20240527/f9b8b3c3cd5f1113bd7d374dc55d320a.jpg",
|
||||
"image"=> "https:multi-store.crmeb.net/uploads/attach/2024/05/20240527/f9b8b3c3cd5f1113bd7d374dc55d320a.jpg",
|
||||
"store_price"=> 797.88,
|
||||
"store_product_count"=> 18,
|
||||
"store_order_price"=> 1275.16,
|
||||
@ -270,7 +270,7 @@ class SystemStoreStatisticsController extends BaseAdminController
|
||||
[
|
||||
"id"=> 43,
|
||||
"name"=> "这是直营店",
|
||||
"image"=> "https=>//multi-store.crmeb.net/uploads/attach/2024/05/20240524/9066528e73e2db60d31a704d321ba4a5.jpeg",
|
||||
"image"=> "https:multi-store.crmeb.net/uploads/attach/2024/05/20240524/9066528e73e2db60d31a704d321ba4a5.jpeg",
|
||||
"store_price"=> 203.11,
|
||||
"store_product_count"=> 10,
|
||||
"store_order_price"=> 579.01,
|
||||
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店日账单列表
|
||||
* Class StoreFinanceFlowDayLists
|
||||
* @package app\admin\listsstore_finance_flow
|
||||
*/
|
||||
class StoreFinanceFlowDayLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'uid', 'staff_id'],
|
||||
'between_time'=>'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店日账单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreFinanceFlow::where($this->searchWhere)
|
||||
->field('
|
||||
FROM_UNIXTIME(create_time, "%Y-%m-%d") as date,
|
||||
SUM(CASE WHEN financial_pm = 1 THEN number ELSE 0 END) as income,
|
||||
SUM(CASE WHEN financial_pm = 0 THEN number ELSE 0 END) as expenditure
|
||||
')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->group('date')
|
||||
->order('date', 'desc')
|
||||
->select()->each(function ($item) {
|
||||
$item['name']='日账单';
|
||||
$item['enter']=bcdiv($item['income'],$item['expenditure'],2);
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店日账单数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreFinanceFlow::where($this->searchWhere)->group('create_time')
|
||||
->count();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店月账单列表
|
||||
* Class StoreFinanceFlowMonthLists
|
||||
* @package app\admin\listsstore_finance_flow
|
||||
*/
|
||||
class StoreFinanceFlowMonthLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'uid', 'staff_id'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店月账单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreFinanceFlow::where($this->searchWhere)
|
||||
->field('
|
||||
CONCAT(YEAR(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "年", MONTH(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "月") as date,
|
||||
SUM(CASE WHEN financial_pm = 1 THEN number ELSE 0 END) as income,
|
||||
SUM(CASE WHEN financial_pm = 0 THEN number ELSE 0 END) as expenditure
|
||||
')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->group('date')
|
||||
->order('date', 'desc')
|
||||
->select()->each(function ($item) {
|
||||
$item['name']='月账单';
|
||||
$item['enter']=bcdiv($item['income'],$item['expenditure'],2);
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店月账单数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreFinanceFlow::where($this->searchWhere)->group('create_time')
|
||||
->count();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店周账单列表
|
||||
* Class StoreFinanceFlowWeekLists
|
||||
* @package app\admin\listsstore_finance_flow
|
||||
*/
|
||||
class StoreFinanceFlowWeekLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'uid', 'staff_id'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店周账单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreFinanceFlow::where($this->searchWhere)
|
||||
->field('
|
||||
CONCAT("第", YEARweek(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "周(", MONTH(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "月)") as date,
|
||||
SUM(CASE WHEN financial_pm = 1 THEN number ELSE 0 END) as income,
|
||||
SUM(CASE WHEN financial_pm = 0 THEN number ELSE 0 END) as expenditure
|
||||
')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->group('date')
|
||||
->order('date', 'desc')
|
||||
->select()->each(function ($item) {
|
||||
$item['name']='周账单';
|
||||
$item['enter']=bcdiv($item['income'],$item['expenditure'],2);
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店周账单数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreFinanceFlow::where($this->searchWhere)->group('create_time')
|
||||
->count();
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace app\admin\lists\system_store;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
/**
|
||||
* 门店列表列表
|
||||
@ -47,7 +47,9 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show','day_start','day_end'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->select()->each(function ($item){
|
||||
$item['staff_name'] =SystemStoreStaff::where('store_id',$item['id'])->where('is_admin',1)->value('staff_name');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace app\admin\lists\user_recharge;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 充值记录列表
|
||||
@ -27,6 +27,7 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
{
|
||||
return [
|
||||
'=' => ['paid', 'pay_time'],
|
||||
'between_time'=>'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -46,7 +47,20 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
->field(['id', 'uid', 'order_id', 'price', 'recharge_type', 'paid', 'pay_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->select()->each(function ($item) {
|
||||
$item['nickname']=User::where('id',$item['uid'])->value('nickname');
|
||||
if($item['pay_time']>0){
|
||||
$item['pay_time']=date('Y-m-d H:i:s',$item['pay_time']);
|
||||
}else{
|
||||
$item['pay_time']='';
|
||||
}
|
||||
if($item['paid']==1){
|
||||
$item['paid_name']='已充值';
|
||||
}else{
|
||||
$item['paid_name']='未充值';
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class SystemStoreLogic extends BaseLogic
|
||||
'account' => $params['phone'],
|
||||
'pwd' => $password,
|
||||
'avatar' => $params['image'],
|
||||
'staff_name' => $params['name'],
|
||||
'staff_name' => $params['staff_name'],
|
||||
'phone' => $params['phone'],
|
||||
'is_admin' => 1,
|
||||
'status' => 1,
|
||||
@ -95,17 +95,24 @@ class SystemStoreLogic extends BaseLogic
|
||||
'area' => $params['area_code'],
|
||||
'street' => $params['street_code'],
|
||||
]);
|
||||
if($params['password']!=''){
|
||||
$res=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->find();
|
||||
if($params['password']!=''&&$res){
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$taff = [
|
||||
'pwd' => $password,
|
||||
'avatar' => $params['image'],
|
||||
'staff_name' => $params['name'],
|
||||
'staff_name' => $params['staff_name'],
|
||||
];
|
||||
SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->update($taff);
|
||||
SystemStoreStaff::where('id', $res['id'])->update($taff);
|
||||
}
|
||||
if($params['staff_name']!=''&&$res){
|
||||
$taff = [
|
||||
'avatar' => $params['image'],
|
||||
'staff_name' => $params['staff_name'],
|
||||
];
|
||||
SystemStoreStaff::where('id', $res['id'])->update($taff);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -138,6 +145,10 @@ class SystemStoreLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return SystemStore::findOrEmpty($params['id'])->toArray();
|
||||
$data=SystemStore::findOrEmpty($params['id'])->toArray();
|
||||
if($data){
|
||||
$data['staff_name']=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->value('staff_name');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,8 @@ class PayController extends BaseApiController
|
||||
{
|
||||
$app = new PayService(1);
|
||||
$result = $app->wechat->callback(Request()->post());
|
||||
Cache::set('log'.time(),json_encode($result));
|
||||
Cache::set('logE'.time(),$result->event_type);
|
||||
Cache::set('logE1'.time(),$result['event_type']??'');
|
||||
if ($result && $result->event_type == 'TRANSACTION.SUCCESS') {
|
||||
$ciphertext = $result->resource['ciphertext'];
|
||||
Cache::set('logc'.time(),json_encode($result->resource['ciphertext'],true));
|
||||
if ($ciphertext['trade_state'] === 'SUCCESS') {
|
||||
$attach = $ciphertext['attach'];
|
||||
switch ($attach) {
|
||||
|
@ -243,13 +243,23 @@ class OrderController extends BaseApiController
|
||||
{
|
||||
$userId = $this->request->userId;
|
||||
$where = ['uid' => $userId, 'paid' => 0];
|
||||
$no_pay = StoreOrder::where($where)->count();
|
||||
$no_pay = StoreOrder::where($where)->count();//待付款
|
||||
|
||||
$where['paid'] = 1;
|
||||
$where['status'] = 0;
|
||||
$waiting = StoreOrder::where($where)->count();
|
||||
$where['status'] = 1;
|
||||
$receiving = StoreOrder::where($where)->count();
|
||||
return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving]);
|
||||
$waiting = StoreOrder::where($where)->count();//待核销
|
||||
|
||||
$where['status'] = 2;
|
||||
$receiving = StoreOrder::where($where)->count();//已核销
|
||||
|
||||
$where['status'] = -1;
|
||||
$applyRefund= StoreOrder::where($where)->count();//申请退款
|
||||
|
||||
$where['status'] = 4;
|
||||
$refund= StoreOrder::where($where)->count();//已退款
|
||||
|
||||
$all = StoreOrder::where(['uid' => $userId])->count();//全部
|
||||
return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving,'all'=>$all,'applyRefund'=>$applyRefund,'refund'=>$refund]);
|
||||
}
|
||||
|
||||
#[
|
||||
|
@ -9,6 +9,8 @@ use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\CapitalFlowLogic;
|
||||
use app\common\logic\StoreFinanceFlowLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
@ -76,10 +78,13 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
//TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级
|
||||
$pay_price = self::$total;
|
||||
$check = StoreOrder::where('uid',\request()->userId)->count();
|
||||
// $check = StoreOrder::where('uid',\request()->userId)->count();//首单逻辑
|
||||
$check = DictType::where('type','activities')->find();
|
||||
$vipPrice = 0;
|
||||
if(empty($check)){
|
||||
$discountRate = '0.99';
|
||||
if(isset($check) && $check['status'] == 1){
|
||||
// $discountRate = '0.99';//首单逻辑
|
||||
$discountRate = $check['remark'];
|
||||
$discountRate = bcdiv($discountRate, '100', 2);
|
||||
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
|
||||
}else{
|
||||
$userVip = User::where('id',\request()->userId)->value('user_ship');
|
||||
@ -103,6 +108,7 @@ class OrderLogic extends BaseLogic
|
||||
default:
|
||||
$discountRate = 1;
|
||||
}
|
||||
$discountRate = bcdiv($discountRate, '100', 2);
|
||||
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class UserLogic extends BaseLogic
|
||||
public static function info($uid)
|
||||
{
|
||||
$data = User::with(['userShip'])->where('id',$uid)
|
||||
->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money,total_recharge_amount,user_ship')
|
||||
->field('avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship')
|
||||
->find();
|
||||
//判断是不是员工
|
||||
if($data){
|
||||
|
@ -130,7 +130,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
return true;
|
||||
}
|
||||
bcscale(2);
|
||||
$user->user_money = bcadd($user->user_money, $price, 2);
|
||||
$user->now_money = bcadd($user->now_money, $price, 2);
|
||||
$user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2);
|
||||
$user->save();
|
||||
//用户的财务add
|
||||
|
Loading…
x
Reference in New Issue
Block a user