This commit is contained in:
liu 2024-06-25 09:51:10 +08:00
commit 00ddc6c5c1
1658 changed files with 8103 additions and 236637 deletions

View File

@ -41,7 +41,7 @@ class WorkbenchController extends BaseAdminController
return $this->data($result);
}
/**
* @notes 工作台
* @notes 门店
* @author 乔峰
* @date 2021/12/29 17=>01
*/
@ -49,7 +49,7 @@ class WorkbenchController extends BaseAdminController
{
$params = $this->request->get();
if(!isset($params['store_id']) ||$params['store_id']==''){
$params['store_id'] =1;
$params['store_id'] =0;
}
if(!isset($params['start_time']) ||$params['start_time']==''){
$time=explode('-', $this->getDay(''));
@ -98,14 +98,32 @@ class WorkbenchController extends BaseAdminController
public function get_trend()
{
$dates = [];
$today = new DateTime();
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
$thirtyDaysAgo->modify('-30 days');
for ($i = 0; $i < 31; $i++) {
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
$date=$this->request->get('date','');
$days=31;
if($date){
$arr=explode('-', $date);
if($arr[0]==$arr[1]){
$date = new DateTime($arr[0]);
$dates[] = $date->format("Y-m-d");
}else{
$datetime_start = new DateTime($arr[0]);
$datetime_end = new DateTime($arr[1]);
$days = $datetime_start->diff($datetime_end)->days;
for ($i = 0; $i <= $days; $i++) {
$date = new DateTime($datetime_start->format('Y-m-d'));
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
}
}
}else{
$today = new DateTime();
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
$thirtyDaysAgo->modify('-30 days');
for ($i = 0; $i < $days; $i++) {
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
}
}
$data = [
"xAxis" => $dates,
@ -218,7 +236,11 @@ class WorkbenchController extends BaseAdminController
if (!$startTime && !$endTime) {
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
} else {
return $startTime . '-' . $endTime;
if($startTime==$endTime){
return $startTime . '-' . $endTime.' 23:59:59';
}else{
return $startTime . '-' . $endTime;
}
}
} else {
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());

View File

@ -10,7 +10,7 @@ use app\admin\validate\financial_transfers\FinancialTransfersValidate;
/**
* FinancialTransfers控制器
* 财务转账控制器
* Class FinancialTransfersController
* @package app\admin\controller\financial_transfers
*/
@ -64,13 +64,6 @@ class FinancialTransfersController extends BaseAdminController
}
/**
* @notes 添加
* @return \think\response\Json

View File

@ -56,6 +56,7 @@ class StoreCashFinanceFlowController extends BaseAdminController
public function edit()
{
$params = (new StoreCashFinanceFlowValidate())->post()->goCheck('edit');
$params['admin_id']=$this->adminId;
$result = StoreCashFinanceFlowLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);

View File

@ -8,6 +8,9 @@ use app\admin\lists\store_order\StoreOrderLists;
use app\admin\lists\store_order\StoreRefundOrderLists;
use app\admin\logic\store_order\StoreOrderLogic;
use app\admin\validate\store_order\StoreOrderValidate;
use app\common\enum\PayEnum;
use app\common\logic\PayNotifyLogic;
use app\common\model\store_order\StoreOrder;
/**
@ -101,5 +104,53 @@ class StoreOrderController extends BaseAdminController
return $this->data($result);
}
/**
* 退款逻辑
* @return \support\Response
* @throws \Exception
*/
public function refund()
{
$params = (new StoreOrderValidate())->goCheck('refund');
$detail = StoreOrder::where('order_id',$params['order_id'])->findOrEmpty();
if(empty($detail)){
return $this->fail('无该订单请检查');
}
//微信支付
if(in_array($detail['pay_type'],[PayEnum::WECHAT_PAY_MINI,PayEnum::WECHAT_PAY_BARCODE])){
$money = (int)bcmul($detail['pay_price'],100);
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
->refund($params['order_id'],$money,$money);
if($refund){
$arr = [
'amount'=>[
'refund'=>$money
]
];
PayNotifyLogic::refund($params['order_id'],$arr);
return $this->success();
}
}
//余额支付 采购款支付
if (in_array($detail['pay_type'] ,[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
$money = bcmul($detail['pay_price'],100);
$arr = [
'amount'=>[
'refund'=>$money
]
];
PayNotifyLogic::refund($params['order_id'],$arr);
return $this->success();
}
//现金支付
if($detail['pay_type'] = PayEnum::CASH_PAY){
PayNotifyLogic::cash_refund($params['order_id']);
return $this->success();
}
//支付包支付
return $this->fail('退款失败');
}
}

View File

@ -6,10 +6,10 @@ namespace app\admin\lists\financial_transfers;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\financial_transfers\FinancialTransfers;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
/**
* FinancialTransfers列表
* 财务转账列表
* Class FinancialTransfersLists
* @package app\admin\listsfinancial_transfers
*/
@ -50,6 +50,9 @@ class FinancialTransfersLists extends BaseAdminDataLists implements ListsSearchI
->toArray();
foreach ($data as &$value){
if($value['initiation_time']){
$time=strtotime('-1 month',$value['initiation_time']);
$date=date('Y-m-d',$time);//获取一个月前的日期
$value['receivable']=StoreCashFinanceFlow::whereMonth('create_time',$date)->where('status',0)->sum('receivable');
$value['initiation_time'] = date('Y-m-d H:i:s',$value['initiation_time']);
}

View File

@ -63,7 +63,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
}
return StoreBranchProduct::where($this->searchWhere)->where($where)
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price'])
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information'])
->when(!empty($this->adminInfo['store_id']), function ($query) {
$query->where('store_id', $this->adminInfo['store_id']);
})

View File

@ -6,7 +6,8 @@ namespace app\admin\lists\store_cash_finance_flow;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\system_store\SystemStore;
/**
* 现金流水列表
@ -26,7 +27,7 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
public function setSearch(): array
{
return [
'=' => ['store_id'],
'=' => ['store_id','status'],
"between_time" => 'create_time'
];
}
@ -47,7 +48,12 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'status'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->select()->each(function ($item) {
$item->store_name =SystemStore::where('id', $item->store_id)->value('name');
if($item->admin_id>0){
$item->admin_name =Admin::where('id', $item->admin_id)->value('name');
}
})
->toArray();
}

View File

@ -54,7 +54,7 @@ class StoreFinanceFlowDayLists extends BaseAdminDataLists implements ListsSearch
->order('date', 'desc')
->select()->each(function ($item) {
$item['name']='日账单';
$item['enter']=bcdiv($item['income'],$item['expenditure'],2);
$item['enter']=bcsub($item['income'],$item['expenditure'],2);
return $item;
})
->toArray();

View File

@ -51,7 +51,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
public function lists(): array
{
$field = [
'id','order_id', 'order_sn', 'create_time', 'other_uid', 'user_id', 'store_id', 'staff_id', 'financial_type', 'financial_pm', 'pay_type', 'type', 'number', 'status'
'id', 'order_id', 'order_sn', 'create_time', 'other_uid', 'user_id', 'store_id', 'staff_id', 'financial_type', 'financial_pm', 'pay_type', 'type', 'number', 'status'
];
$this->searchWhere[] = ['financial_type', '=', 1];
$this->searchWhere[] = ['financial_pm', '=', 1];
@ -82,7 +82,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
})->toArray();
foreach ($data as $key => $item) {
$list1= StoreFinanceFlow::where('order_id' ,$item['order_id'])->where('financial_type','>', 1)->field($field)->order('financial_pm','desc')->select()->each(function ($item) {
$list1 = StoreFinanceFlow::where('order_id', $item['order_id'])->where('financial_type', '>', 1)->field($field)->select()->each(function ($item) {
if ($item['user_id'] <= 0) {
$item['nickname'] = '游客';
} else {
@ -103,19 +103,34 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
});
$list2=UserSign::where('order_id',$item['order_sn'])->whereIn('user_ship',[2,3])->select();
foreach($list2 as $k=>$v){
$list2[$k]['id']='jf'.$v['id'];
$list2[$k]['order_sn']=$item['order_sn'];
$list2[$k]['store_name']=$item['store_name'];
$list2[$k]['financial_pm']=0;
$list2[$k]['nickname']=$v['uid']>0?User::where('id', $v['uid'])->value('nickname') . '|'.$v['uid']:'游客';
$list2[$k]['number']='+'.$v['number'];
$list2[$k]['financial_type_name']=$v['title'];
$list2 = UserSign::where('order_id', $item['order_sn'])->whereIn('user_ship', [0, 2, 3])->select();
foreach ($list2 as $k => $v) {
$list2[$k]['id'] = 'JF' . $v['id'];
$list2[$k]['order_sn'] = $item['order_sn'];
$list2[$k]['store_name'] = $item['store_name'];
if($v['user_ship']==0){
$list2[$k]['financial_pm'] = 1;
$list2[$k]['number'] = '+' . $v['number'];
}else{
if($v['financial_pm']==1){
$list2[$k]['financial_pm'] = 1;
$list2[$k]['number'] = '+' . $v['number'];
}else{
$list2[$k]['financial_pm'] = 0;
$list2[$k]['number'] = '-' . $v['number'];
}
}
$list2[$k]['nickname'] = $v['uid'] > 0 ? User::where('id', $v['uid'])->value('nickname') . '|' . $v['uid'] : '游客';
$list2[$k]['financial_type_name'] = $v['title'];
$list2[$k]['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
}
$data[$key]['list']=array_merge($list1->toArray(),$list2->toArray());
$list3 = array_merge($list1->toArray(), $list2->toArray());
// 提取 financial_pm 字段到单独的数组
$financial_pm = array_column($list3, 'financial_pm');
// 对 financial_pm 数组进行排序,这将影响原始数组
array_multisort($financial_pm, SORT_ASC, $list3);
$data[$key]['list']=$list3;
}
return $data;
}

View File

@ -54,7 +54,7 @@ class StoreFinanceFlowMonthLists extends BaseAdminDataLists implements ListsSear
->order('date', 'desc')
->select()->each(function ($item) {
$item['name']='月账单';
$item['enter']=bcdiv($item['income'],$item['expenditure'],2);
$item['enter']=bcsub($item['income'],$item['expenditure'],2);
return $item;
})
->toArray();

View File

@ -54,7 +54,7 @@ class StoreFinanceFlowWeekLists extends BaseAdminDataLists implements ListsSearc
->order('date', 'desc')
->select()->each(function ($item) {
$item['name']='周账单';
$item['enter']=bcdiv($item['income'],$item['expenditure'],2);
$item['enter']=bcsub($item['income'],$item['expenditure'],2);
return $item;
})
->toArray();

View File

@ -9,6 +9,7 @@ use app\common\enum\PayEnum;
use app\common\model\store_order\StoreOrder;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
/**
* 订单列表列表
@ -45,9 +46,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
$query->field(['id', 'oid', 'product_id', 'cart_info']);
}])->where($this->searchWhere)
return StoreOrder::with(['user', 'staff'])->where($this->searchWhere)
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
$query->where('store_id', $this->request->adminInfo['store_id']);
})
@ -59,7 +58,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
$query->whereIn('status', $status);
}
})
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid'])
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid','refund_status'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
@ -68,13 +67,13 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
if ($item['paid'] == 0) {
$item['status_name'] = '待支付';
}
$product_count = count($item['product']) >= 3 ? 3 : count($item['product']);
for ($i = 0; $i < $product_count; $i++) {
$find = StoreBranchProduct::where('product_id', $item['product'][$i]['product_id'])->field('store_name,image')->find();
$item['product'][$i]['store_name'] = $find['store_name'];
$item['product'][$i]['image'] = $find['image'];
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
->limit(3)->select();
foreach ($product as &$items) {
$items['store_name'] = $items['cart_info']['name'];
$items['image'] = $items['cart_info']['image'];
}
$item['product'] = $product;
return $item;
})
->toArray();

View File

@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
public function lists(): array
{
return StoreProduct::where($this->searchWhere)
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code'])
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {

View File

@ -53,7 +53,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
$where[] = ['is_disable','=', $params['is_disable']];
}
$field = "id,nickname,real_name,sex,avatar,account,mobile,channel,create_time,purchase_funds,user_ship,
label_id,integral";
label_id,integral,now_money,total_recharge_amount";
$lists = User::withSearch($this->setSearch(), $this->params)->where($where)
->with(['user_ship','user_label'])
->limit($this->limitOffset, $this->limitLength)

View File

@ -72,15 +72,17 @@ class WorkbenchLogic extends BaseLogic
public static function get_basic($where)
{
$browse = StoreVisit::where($where)->count();
$user = 0;
$user = StoreVisit::where($where)->group('uid')->count();
$cart = Cart::where($where)->where('is_fail', 0)->sum('cart_num');
$order = StoreOrder::where($where)->count();
$payPeople = StoreOrder::where($where)->where('paid', 1)->group('uid')->count();
$pay = StoreOrder::where($where)->where('paid', 1)->where('refund_status', 0)->count();
$payPrice = StoreOrder::where($where)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
$cost = StoreOrder::where($where)->where('paid', 1)->sum('cost');
$refundPrice = StoreOrder::where($where)->where('status', 'in', [-1, -2])->sum('refund_price');
$refund = StoreOrder::where($where)->where('status', 'in', [-1, -2])->count();
$payPercent = 0;
$refundPrice = StoreOrder::where($where)->where('refund_status', 2)->sum('refund_price');
$refund = StoreOrder::where($where)->where('refund_status',2)->count();
$payPercent = bcmul((string)($user > 0 ? bcdiv($payPeople, $user, 4) : 0), '100', 2); //访客-付款转化率
return [
'browse' => ['num' => $browse, 'title' => '浏览量'], //浏览量
'user' => ['num' => $user, 'title' => '访客数'], //访客数
@ -136,7 +138,7 @@ class WorkbenchLogic extends BaseLogic
{
$data = [];
foreach ($dates as $date) {
$data[] = StoreOrder::whereDay('create_time', $date)->where('status', 'in', [-1, -2])->cache('refundPrice_' . $date, 300)->where('paid', 1)->sum('pay_price');
$data[] = StoreOrder::whereDay('create_time', $date)->where('refund_status', 2)->cache('refundPrice_' . $date, 300)->where('paid', 1)->sum('pay_price');
}
return $data;
}

View File

@ -5,6 +5,7 @@ namespace app\admin\logic\financial_transfers;
use app\common\model\financial_transfers\FinancialTransfers;
use app\common\logic\BaseLogic;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use think\facade\Db;
@ -112,45 +113,46 @@ class FinancialTransfersLogic extends BaseLogic
{
Db::startTrans();
try {
FinancialTransfers::where('id',$params['id'])
FinancialTransfers::where('id', $params['id'])
->update(
[
'status'=>1,
'initiation_time'=>time()
'status' => 1,
'initiation_time' => time()
]
);
Db::commit();
return true;
}catch (\Exception $e) {
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
public static function dealchange($params,$id)
public static function dealchange($params, $id)
{
$find = FinancialTransfers::where('id', $id)->find();
$time = strtotime('-1 month', $find['initiation_time']);
$date = date('Y-m-d', $time); //获取一个月前的日期
$receivable = StoreCashFinanceFlow::whereMonth('create_time', $date)->where('status', 0)->sum('receivable');
if($receivable==0){
self::setError('暂无法确认,还有未收取的现金');
}
Db::startTrans();
try {
FinancialTransfers::where('id',$id)
FinancialTransfers::where('id', $id)
->update(
$params
);
Db::commit();
return true;
}catch (\Exception $e) {
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -3,6 +3,7 @@
namespace app\admin\logic\statistic;
use app\common\logic\BaseLogic;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_log\StoreProductLog;
/**
@ -14,7 +15,9 @@ class ProductStatisticLogic extends BaseLogic
public function get_product_ranking($where)
{
$list = StoreProductLog::where($where)->with('store')
$time = explode('-', $where['create_time']);
$time = [strtotime($time[0]), strtotime($time[1])];
$list = StoreProductLog::whereBetweenTime('create_time',$time[0],$time[1])
->field([
'store_id',
'product_id',
@ -29,11 +32,11 @@ class ProductStatisticLogic extends BaseLogic
'SUM(collect_num) as collect',
'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes',
'COUNT(distinct(pay_uid))-1 as repeats'
])->group('product_id')->order('pay' . ' desc')->limit(20)->select()->toArray();
])->group('product_id')->order('pay'.' desc')->limit(10)->select()->toArray();
foreach ($list as $key => &$item) {
if (!$item['store_name']) {
unset($list[$key]);
}
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->find();
$item['store_name']=$find['store_name'];
$item['image']=$find['image'];
if ($item['profit'] == null) $item['profit'] = 0;
if ($item['changes'] == null) $item['changes'] = 0;
if ($item['repeats'] == null) {
@ -42,6 +45,6 @@ class ProductStatisticLogic extends BaseLogic
$item['repeats'] = bcdiv(count(StoreProductLog::where($where)->where('type', 'pay')->where('product_id', $item['product_id'])->field('count(pay_uid) as p')->group('pay_uid')->having('p>1')->select()), $item['repeats'], 2);
}
}
return array_merge($list);
return $list;
}
}

View File

@ -3,8 +3,10 @@
namespace app\admin\logic\statistic;
use app\common\logic\BaseLogic;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\user_recharge\UserRecharge;
use app\common\model\user_sign\UserSign;
/**
* Class 交易数据
@ -222,52 +224,62 @@ class TradeStatisticLogic extends BaseLogic
$Chain['goods'] = $OrderCurve;
/** 购买会员金额 */
// $memberMoney = $this->getMemberTotalMoney($where, 'sum');
// $lastMemberMoney = $this->getMemberTotalMoney($dateWhere, 'sum', "", $isNum);
// $memberCurve = $this->getMemberTotalMoney($where, 'group', "create_time");
// $MemberChain = countRate($memberMoney, $lastMemberMoney);
// $topData[3] = [
// 'title' => '购买会员金额',
// 'desc' => '选定条件下,用户成功购买付费会员的金额',
// 'total_money' => $memberMoney,
// 'rate' => $MemberChain,
// 'value' => $memberCurve['y'],
// 'type' => 1,
// 'sign' => 'member',
// ];
// $Chain['member'] = $memberCurve;
/** 充值金额 */
$rechgeMoneyHome = $this->getRechargeTotalMoney($where, 'sum');
$rechgeMoneyAdmin = $this->getBillYeTotalMoney($where, 'sum');
$rechgeMoneyTotal = bcadd($rechgeMoneyHome, $rechgeMoneyAdmin, 2);
$lastRechgeMoneyHome = $this->getRechargeTotalMoney($dateWhere, 'sum', "", $isNum);
$lastRechgeMoneyAdmin = $this->getBillYeTotalMoney($dateWhere, 'sum', "", $isNum);
$lastRechgeMoneyTotal = bcadd($lastRechgeMoneyHome, $lastRechgeMoneyAdmin, 2);
$RechgeHomeCurve = $this->getRechargeTotalMoney($where, 'group', "create_time");
$RechgeAdminCurve = $this->getBillYeTotalMoney($where, 'group', "create_time");
$RechgeTotalCurve = $this->totalArrData([$RechgeHomeCurve, $RechgeAdminCurve]);
$RechgeChain = countRate($rechgeMoneyTotal, $lastRechgeMoneyTotal);
$topData[4] = [
'title' => '充值金额',
'desc' => '选定条件下,用户成功充值的金额',
'total_money' => $rechgeMoneyTotal,
'rate' => $RechgeChain,
'value' => $RechgeTotalCurve['y'],
//微信支付商品
$wechatOrderMoney = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $where['create_time']], 'sum');
$lastWechatOrderMoney = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
$wechatOrderCurve = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $where['create_time']], 'group', 'create_time');
$wechatOrderChain = countRate($wechatOrderMoney, $lastWechatOrderMoney);
$topData[3] = [
'title' => '微信支付金额',
'desc' => '用户下单时使用微信实际支付的金额',
'total_money' => $wechatOrderMoney,
'rate' => $wechatOrderChain,
'value' => $wechatOrderCurve['y'],
'type' => 1,
'sign' => 'rechge',
'sign' => 'wechat',
];
$Chain['rechage'] = $RechgeTotalCurve;
$Chain['wechat'] = $wechatOrderCurve;
//支付宝支付商品
$aliPayOrderMoney = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $where['create_time']], 'sum');
$lastAlipayOrderMoney = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
$aliPayOrderCurve = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $where['create_time']], 'group', 'create_time');
$aliPayOrderChain = countRate($aliPayOrderMoney, $lastAlipayOrderMoney);
$topData[4] = [
'title' => '支付宝支付金额',
'desc' => '用户下单时使用支付宝实际支付的金额',
'total_money' => $aliPayOrderMoney,
'rate' => $aliPayOrderChain,
'value' => $aliPayOrderCurve['y'],
'type' => 1,
'sign' => 'ali_pay',
];
$Chain['ali_pay'] = $aliPayOrderCurve;
//采购款支付商品
$fundsOrderMoney = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $where['create_time']], 'sum');
$lastFundsOrderMoney = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
$fundsOrderCurve = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $where['create_time']], 'group', 'create_time');
$fundsOrderChain = countRate($fundsOrderMoney, $lastFundsOrderMoney);
$topData[5] = [
'title' => '采购支付金额',
'desc' => '用户下单时使用采购实际支付的金额',
'total_money' => $fundsOrderMoney,
'rate' => $fundsOrderChain,
'value' => $fundsOrderCurve['y'],
'type' => 1,
'sign' => 'funds',
];
$Chain['funds'] = $fundsOrderCurve;
/** 线下收银 */
$offlineMoney = $this->getOfflineTotalMoney($where, 'sum');
$lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum);
$offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time");
$offlineChain = countRate($offlineMoney, $lastOfflineMoney);
$topData[5] = [
'title' => '线下收银金额',
'desc' => '选定条件下,用户在线下扫码支付的金额',
$topData[6] = [
'title' => '现金收银金额',
'desc' => '选定条件下,用户在线下现金支付的金额',
'total_money' => $offlineMoney,
'rate' => $offlineChain,
'value' => $offlineCurve['y'],
@ -282,18 +294,8 @@ class TradeStatisticLogic extends BaseLogic
$lastOutYeOrderMoney = $this->getOrderTotalMoney(['pay_type' => 3, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
$outYeOrderCurve = $this->getOrderTotalMoney(['pay_type' => 3, 'create_time' => $where['create_time']], 'group', 'create_time');
$outYeOrderChain = countRate($outYeOrderMoney, $lastOutYeOrderMoney);
//余额购买会员
// $outYeMemberMoney = $this->getMemberTotalMoney(['pay_type' => "yue", 'time' => $where['time']], 'sum');
// $lastOutYeMemberMoney = $this->getMemberTotalMoney(['pay_type' => "yue", 'time' => $dateWhere['time']], 'sum', "", $isNum);
// $outYeMemberCurve = $this->getMemberTotalMoney(['pay_type' => "yue", 'time' => $where['time']], 'group', "pay_time");
// $outYeMemberChain = countRate($outYeMemberMoney, $lastOutYeMemberMoney);
//余额支付
// $outYeMoney = bcadd($outYeOrderMoney, $outYeMemberMoney, 2);
// $lastOutYeMoney = bcadd($lastOutYeOrderMoney, $lastOutYeMemberMoney, 2);
// $outYeCurve = $this->totalArrData([$outYeOrderCurve, $outYeMemberCurve]);
// $outYeChain = countRate($outYeOrderChain, $outYeMemberChain);
$outYeMoney = $outYeOrderMoney;
$lastOutYeMoney = $lastOutYeOrderMoney;
$outYeCurve = $this->totalArrData([$outYeOrderCurve, 0]);
$outYeChain = countRate($outYeOrderChain, 0);
$topData[7] = [
@ -307,29 +309,87 @@ class TradeStatisticLogic extends BaseLogic
];
$Chain['out_ye'] = $outYeCurve;
//保证金金额
$depositWehre = $where;
$depositWehre['financial_type'] = 11;
$orderDepositMoney = $this->getFinanceFlow($depositWehre, "sum");
$lastOrderDepositMoney = $this->getFinanceFlow($dateWhere, "sum", "", $isNum);
$OrderDepositCurve = $this->getFinanceFlow($where, "group", "create_time");
$OrderDepositChain = countRate($orderDepositMoney, $lastOrderDepositMoney);
//支付佣金金额
// $outExtractMoney = $this->getExtractTotalMoney($where, 'sum');
// $lastOutExtractMoney = $this->getExtractTotalMoney($dateWhere, 'sum', "", $isNum);
// $OutExtractCurve = $this->getExtractTotalMoney($where, 'group', "add_time");
// $OutExtractChain = countRate($outExtractMoney, $lastOutExtractMoney);
// $topData[8] = [
// 'title' => '支付佣金金额',
// 'desc' => '后台给推广员支付的推广佣金,以实际支付为准',
// 'total_money' => $outExtractMoney,
// 'rate' => $OutExtractChain,
// 'value' => $OutExtractCurve['y'],
// 'type' => 0,
// 'sign' => 'yong',
$topData[8] = [
'title' => '保证金金额',
'desc' => '门店未交满,订单扣除的保证金',
'total_money' => $orderDepositMoney,
'rate' => $OrderDepositChain,
'value' => $OrderDepositCurve['y'],
'type' => 1,
'sign' => 'deposit',
];
$Chain['deposit'] = $OrderDepositCurve;
//兑换礼品券
$userSign = $this->getUserSign($where, 'sum');
$userSignTwo = $this->getUserSign($where, 'sum', "", $isNum);
$userSignGroup = $this->getUserSign($where, 'group', "create_time");
$userSignRate = countRate($userSign, $userSignTwo);
$topData[9] = [
'title' => '兑换礼品券',
'desc' => '后台给推广员支付的兑换礼品券,以实际支付为准',
'total_money' => $userSign,
'rate' => $userSignRate,
'value' => $userSignGroup['y'],
'type' => 1,
'sign' => 'user_sign',
];
$Chain['user_sign'] = $userSignGroup;
/** 充值金额 */
$rechgeMoneyHome = $this->getRechargeTotalMoney($where, 'sum');
$rechgeMoneyAdmin = $this->getBillYeTotalMoney($where, 'sum');
$rechgeMoneyTotal = bcadd($rechgeMoneyHome, $rechgeMoneyAdmin, 2);
$lastRechgeMoneyHome = $this->getRechargeTotalMoney($dateWhere, 'sum', "", $isNum);
$lastRechgeMoneyAdmin = $this->getBillYeTotalMoney($dateWhere, 'sum', "", $isNum);
$lastRechgeMoneyTotal = bcadd($lastRechgeMoneyHome, $lastRechgeMoneyAdmin, 2);
$RechgeHomeCurve = $this->getRechargeTotalMoney($where, 'group', "create_time");
$RechgeAdminCurve = $this->getBillYeTotalMoney($where, 'group', "create_time");
$RechgeTotalCurve = $this->totalArrData([$RechgeHomeCurve, $RechgeAdminCurve]);
$RechgeChain = countRate($rechgeMoneyTotal, $lastRechgeMoneyTotal);
$topData[10] = [
'title' => '充值金额',
'desc' => '选定条件下,用户成功充值的金额',
'total_money' => $rechgeMoneyTotal,
'rate' => $RechgeChain,
'value' => $RechgeTotalCurve['y'],
'type' => 1,
'sign' => 'rechge',
];
$Chain['rechage'] = $RechgeTotalCurve;
//支出金额
// $outTotalMoney = bcadd($outYeMoney, $outExtractMoney, 2);
// $lastOutTotalMoney = bcadd($lastOutYeMoney, $lastOutExtractMoney, 2);
// $outTotalCurve = $this->totalArrData([$outYeCurve, $OutExtractCurve]);
// $outTotalMoney = bcadd($outYeMoney, 0, 2);
// $lastOutTotalMoney = bcadd($lastOutYeMoney, 0, 2);
// $outTotalCurve = $this->totalArrData([$outYeCurve, 0]);
// $outTotalChain = countRate($outTotalMoney, $lastOutTotalMoney);
// $topData[11] = [
// 'title' => '支出金额',
// 'desc' => '余额支付金额、支付佣金金额',
// 'total_money' => $outTotalMoney,
// 'rate' => $outTotalChain,
// 'value' => $outTotalCurve['y'],
// 'type' => 1,
// 'sign' => 'out',
// ];
// $Chain['extract'] = $OutExtractCurve;
// $Chain['out'] = $outTotalCurve;
//商品退款金额
$outOrderRefund = $this->getOrderRefundTotalMoney(['refund_type' => 6, 'create_time' => $where['create_time']], 'sum');
$lastOutOrderRefund = $this->getOrderRefundTotalMoney(['refund_type' => 6, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
$outOrderRefundCurve = $this->getOrderRefundTotalMoney(['refund_type' => 6, 'create_time' => $where['create_time']], 'group', 'create_time');
$outOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'sum');
$lastOutOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
$outOrderRefundCurve = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'group', 'create_time');
$orderRefundChain = countRate($outOrderRefund, $lastOutOrderRefund);
$topData[9] = [
$topData[12] = [
'title' => '商品退款金额',
'desc' => '用户成功退款的商品金额',
'total_money' => $outOrderRefund,
@ -340,44 +400,7 @@ class TradeStatisticLogic extends BaseLogic
];
$Chain['refund'] = $outOrderRefundCurve;
//支出金额
// $outTotalMoney = bcadd($outYeMoney, $outExtractMoney, 2);
// $lastOutTotalMoney = bcadd($lastOutYeMoney, $lastOutExtractMoney, 2);
// $outTotalCurve = $this->totalArrData([$outYeCurve, $OutExtractCurve]);
$outTotalMoney = bcadd($outYeMoney, 0, 2);
$lastOutTotalMoney = bcadd($lastOutYeMoney, 0, 2);
$outTotalCurve = $this->totalArrData([$outYeCurve, 0]);
$outTotalChain = countRate($outTotalMoney, $lastOutTotalMoney);
$topData[6] = [
'title' => '支出金额',
'desc' => '余额支付金额、支付佣金金额',
'total_money' => $outTotalMoney,
'rate' => $outTotalChain,
'value' => $outTotalCurve['y'],
'type' => 1,
'sign' => 'out',
];
$Chain['out'] = $outTotalCurve;
/** 交易毛利金额*/
// $jiaoyiMoney = $this->tradeTotalMoney($where, "sum");
// $jiaoyiMoney = bcsub($jiaoyiMoney, $outTotalMoney, 2);
// $lastJiaoyiMoney = $this->tradeTotalMoney($dateWhere, "sum", $isNum);
// $lastJiaoyiMoney = bcsub($lastJiaoyiMoney, $lastOutTotalMoney, 2);
// $jiaoyiCurve = $this->tradeGroupMoney($where, "group");
// $jiaoyiCurve = $this->subdutionArrData($jiaoyiCurve, $outTotalCurve);
// $jiaoyiChain = countRate($jiaoyiMoney, $lastJiaoyiMoney);
// $topData[1] = [
// 'title' => '交易毛利金额',
// 'desc' => '交易毛利金额 = 营业额 - 支出金额',
// 'total_money' => $jiaoyiMoney,
// 'rate' => $jiaoyiChain,
// 'value' => $jiaoyiCurve['y'],
// 'type' => 1,
// 'sign' => 'jiaoyi',
// ];
// $Chain['jiaoyi'] = $jiaoyiCurve;
/** @var 营业额 $inTotalMoney */
$inTotalMoney = $this->tradeTotalMoney($where, "sum");
@ -396,7 +419,7 @@ class TradeStatisticLogic extends BaseLogic
ksort($topData);
$data = [];
foreach ($topData as $k => $v) {
$data['x'] = $Chain['out']['x'];
// $data['x'] = $Chain['out']['x'];
$data['series'][$k]['name'] = $v['title'];
$data['series'][$k]['desc'] = $v['desc'];
$data['series'][$k]['money'] = $v['total_money'];
@ -430,9 +453,10 @@ class TradeStatisticLogic extends BaseLogic
//购买会员收入
$inMemberMoney = $this->getMemberTotalMoney($where, $selectType, "", $isNum);
//线下收款收入
$inOfflineMoney = $this->getOfflineTotalMoney($where, $selectType, "", $isNum);
// $inOfflineMoney = $this->getOfflineTotalMoney($where, $selectType, "", $isNum);
//总交易额
$inTotalMoney = bcadd(bcadd($inOrderMoney, $inRechargeMoney, 2), bcadd($inMemberMoney, $inOfflineMoney, 2), 2);/* - $outExtractUserMoney*/
// $inTotalMoney = bcadd(bcadd($inOrderMoney, $inRechargeMoney, 2), bcadd($inMemberMoney, $inOfflineMoney, 2), 2);/* - $outExtractUserMoney*/
$inTotalMoney = bcadd(bcadd($inOrderMoney, $inRechargeMoney, 2), $inMemberMoney, 2);/* - $outExtractUserMoney*/
return $inTotalMoney;
}
@ -476,21 +500,22 @@ class TradeStatisticLogic extends BaseLogic
{
$storeOrder = new StoreOrder();
$orderSumField = "pay_price";
$where[] = ['refund_status', '>', 0];
$whereOrder[] = ['refund_status', '>', 0];
$whereOrder['refund_type'] = 6;
$timeKey = $this->TimeConvert($where['create_time'], $isNum);
$where['timeKey'] = $timeKey;
// $where['is_cancel'] = 0;
switch ($selectType) {
case "sum":
$totalMoney = $storeOrder->where($where)->when(isset($where['timeKey']), function ($query) use ($where) {
$totalMoney = $storeOrder->where($whereOrder)->when(isset($where['timeKey']), function ($query) use ($where) {
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
})->sum($orderSumField);
break;
case "group":
$totalMoney = $storeOrder->where($where)->when(isset($where['timeKey']), function ($query) use ($where) {
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
})->count($orderSumField);
$totalMoney = $storeOrder->getCurveData($whereOrder, $where, 'sum(pay_price)');
break;
default:
throw new \Exception('getOrderTotalMoney:selectType参数错误');
throw new \Exception('getOrderRefundTotalMoney:selectType参数错误');
}
if ($group) {
$totalMoney = $this->trendYdata((array)$totalMoney, $this->TimeConvert($where['create_time'], $isNum));
@ -498,6 +523,72 @@ class TradeStatisticLogic extends BaseLogic
return $totalMoney;
}
/**
* 获取兑换卷
* @param $where
* @param string $selectType
* @param string $group
* @param bool $isNum
* @return array|float|int
* @throws \Exception
*/
public function getUserSign($where, string $selectType, string $group = '', bool $isNum = false)
{
$UserSign = new UserSign();
$orderSumField = "number";
$whereUserSign = ['financial_pm' => 1];
$timeKey = $this->TimeConvert($where['create_time'], $isNum);
$where['timeKey'] = $timeKey;
switch ($selectType) {
case "sum":
$totalMoney = $UserSign->where($whereUserSign)->when(isset($where['timeKey']), function ($query) use ($where) {
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
})->sum($orderSumField);
break;
case "group":
$totalMoney = $UserSign->getCurveData($whereUserSign, $where, 'sum(number)');
break;
default:
throw new \Exception('getUserSign:selectType参数错误');
}
if ($group) {
$totalMoney = $this->trendYdata((array)$totalMoney, $this->TimeConvert($where['create_time'], $isNum));
}
return $totalMoney;
}
/**
* 财务流水
* @param $where
* @param string $selectType
* @param string $group
* @param bool $isNum
* @return array|float|int
* @throws \Exception
*/
public function getFinanceFlow($where, string $selectType, string $group = '', bool $isNum = false)
{
$store_finance_flow = new StoreFinanceFlow();
$timeKey = $this->TimeConvert($where['create_time'], $isNum);
unset($where['create_time']);
$time['timeKey'] = $timeKey;
switch ($selectType) {
case "sum":
$totalMoney = $store_finance_flow->where($where)->when(isset($time['timeKey']), function ($query) use ($time) {
$query->whereBetweenTime('create_time', strtotime($time['timeKey']['start_time']), strtotime($time['timeKey']['end_time']));
})->sum('number');
break;
case "group":
$totalMoney = $store_finance_flow->getCurveData($where, $time, 'sum(number)');
break;
default:
throw new \Exception('getFinanceFlow:selectType参数错误');
}
if ($group) {
$totalMoney = $this->trendYdata((array)$totalMoney, $this->TimeConvert($timeKey, $isNum));
}
return $totalMoney;
}
/**
* 获取商品营收
* @param $where
@ -511,37 +602,20 @@ class TradeStatisticLogic extends BaseLogic
{
/** 普通商品订单支付金额 */
$storeOrder = new StoreOrder();
$whereOrderMoner['refund_status'] = isset($where['refund_status']) ? $where['refund_status'] : [0, 3];
$whereOrderMoner['paid'] = 1;
$where['refund_status'] = isset($where['refund_status']) ? $where['refund_status'] : [0, 3];
$where['paid'] = 1;
$timeKey = $this->TimeConvert($where['create_time'], $isNum);
$where['timeKey'] = $timeKey;
unset($where['create_time']);
$time['timeKey'] = $timeKey;
switch ($selectType) {
case "sum":
$totalMoney = $storeOrder->where($whereOrderMoner)->when(isset($where['timeKey']), function ($query) use ($where) {
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
$totalMoney = $storeOrder->where($where)->when(isset($time['timeKey']), function ($query) use ($time) {
$query->whereBetweenTime('create_time', strtotime($time['timeKey']['start_time']), strtotime($time['timeKey']['end_time']));
})->sum('pay_price');
break;
case "group":
$totalMoney = $storeOrder->where($whereOrderMoner)->when(isset($where['timeKey']), function ($query) use ($where, $group) {
$query->whereBetweenTime('create_time', $where['timeKey']['start_time'], $where['timeKey']['end_time']);
if ($where['timeKey']['days'] == 1) {
$timeUinx = "%H";
} elseif ($where['timeKey']['days'] == 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($where['timeKey']['days'] == 365) {
$timeUinx = "%Y-%m";
} elseif ($where['timeKey']['days'] > 1 && $where['timeKey']['days'] < 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
$timeUinx = "%Y-%m";
} else {
$timeUinx = "%Y-%m";
}
$query->field("sum(pay_price) as number,FROM_UNIXTIME($group, '$timeUinx') as time");
$query->group("FROM_UNIXTIME($group, '$timeUinx')");
})
->order('create_time ASC')->select()->toArray();
$totalMoney = $storeOrder->getCurveData($where, $time, 'sum(pay_price)', $group);
break;
default:
throw new \Exception('getOrderTotalMoney:selectType参数错误');
@ -580,26 +654,7 @@ class TradeStatisticLogic extends BaseLogic
->sum($rechargeSumField);
break;
case "group":
$totalMoney = $userRechage->where(['paid' => 1])
->when(isset($where['create_time']), function ($query) use ($where, $rechargeSumField, $group) {
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
if ($where['timeKey']['days'] == 1) {
$timeUinx = "%H";
} elseif ($where['timeKey']['days'] == 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($where['timeKey']['days'] == 365) {
$timeUinx = "%Y-%m";
} elseif ($where['timeKey']['days'] > 1 && $where['timeKey']['days'] < 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
$timeUinx = "%Y-%m";
} else {
$timeUinx = "%Y-%m";
}
$query->field("sum($rechargeSumField) as number,FROM_UNIXTIME($group, '$timeUinx') as time");
$query->group("FROM_UNIXTIME($group, '$timeUinx')");
})
->order('time ASC')->select()->toArray();
$totalMoney = $userRechage->getCurveData(['paid' => 1], $where, 'sum(price)', $group);
break;
default:
$totalMoney = 0.00;
@ -689,33 +744,15 @@ class TradeStatisticLogic extends BaseLogic
// }
switch ($selectType) {
case "sum":
$totalMoney = $storeOrder->where('pay_type', 'in', [9, 13, 17])->when(isset($where['timeKey']), function ($query) use ($where) {
$totalMoney = $storeOrder->where('pay_type', 17)->when(isset($where['timeKey']), function ($query) use ($where) {
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
})->sum($offlineSumField);
break;
case "group":
$totalMoney = $storeOrder->where('pay_type', 'in', [9, 13, 17])->when(isset($where['timeKey']), function ($query) use ($where, $group) {
$query->whereBetweenTime('create_time', $where['timeKey']['start_time'], $where['timeKey']['end_time']);
if ($where['timeKey']['days'] == 1) {
$timeUinx = "%H";
} elseif ($where['timeKey']['days'] == 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($where['timeKey']['days'] == 365) {
$timeUinx = "%Y-%m";
} elseif ($where['timeKey']['days'] > 1 && $where['timeKey']['days'] < 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
$timeUinx = "%Y-%m";
} else {
$timeUinx = "%Y-%m";
}
$query->field("sum(pay_price) as number,FROM_UNIXTIME($group, '$timeUinx') as time");
$query->group("FROM_UNIXTIME($group, '$timeUinx')");
})
->order('time ASC')->select()->toArray();
$totalMoney = $storeOrder->getCurveData(['pay_type' => 17], $where, 'sum(pay_price)', $group);
break;
default:
throw new \Exception('getOrderTotalMoney:selectType参数错误');
throw new \Exception('getOfflineTotalMoney:selectType参数错误');
}
if ($group) {
$totalMoney = $this->trendYdata((array)$totalMoney, $this->TimeConvert($where['create_time'], $isNum));

View File

@ -93,7 +93,6 @@ class UserStatisticLogic extends BaseLogic
{
$time = explode('-', $where['create_time']);
$time = [strtotime($time[0]), strtotime($time[1])];
$channelType = ''; //$where['channel_type'];
if (count($time) != 2) throw new Exception('参数错误');
$dayCount = ($time[1] - $time[0]) / 86400 + 1;

View File

@ -54,7 +54,9 @@ class StoreCashFinanceFlowLogic extends BaseLogic
Db::startTrans();
try {
StoreCashFinanceFlow::where('id', $params['id'])->update([
'file' => $params['file']
'file' => $params['file'],
'status'=>1,
'admin_id'=>$params['admin_id'],
]);
Db::commit();

View File

@ -49,6 +49,7 @@ class StoreProductLogic extends BaseLogic
'purchase' => $params['purchase'],
'rose' => $params['rose'],
'is_return' => $params['is_return'],
'manufacturer_information' => $params['manufacturer_information']??'',
'swap' => $params['swap'] ?? 0,
'batch' => $params['batch'] ?? 0,
];
@ -77,13 +78,13 @@ class StoreProductLogic extends BaseLogic
if ($params['is_store_all'] == 1) {
$store_arr = SystemStore::where('is_show', 1)->column('id');
foreach ($store_arr as $store_id) {
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id,'stock_type'=>1, 'admin_id' => Request()->adminId]);
}
// Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]);
} else {
if (is_array($params['store_arr']) && count($params['store_arr']) > 0) {
foreach ($params['store_arr'] as $key => $store_id) {
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id,'stock_type'=>1, 'admin_id' => Request()->adminId]);
}
// Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]);
}
@ -149,6 +150,7 @@ class StoreProductLogic extends BaseLogic
'price' => $params['price'],
'vip_price' => $params['vip_price'],
'batch' => $params['batch'],
'manufacturer_information' => $params['manufacturer_information']??'',
'swap' => $params['swap'] ?? 0,
];
@ -176,8 +178,9 @@ class StoreProductLogic extends BaseLogic
//修改
StoreBranchProduct::where('product_id', $params['id'])->update([
'price' => $params['price'], 'vip_price' => $params['vip_price'],
'cost' => $params['cost'],
'batch'=>$params['batch'],'store_name'=>$params['store_name']
'cost' => $params['cost'],'unit'=>$params['unit'],
'batch'=>$params['batch'],'store_name'=>$params['store_name'],
'manufacturer_information' => $params['manufacturer_information']??'',
]);
Db::commit();
@ -290,6 +293,7 @@ class StoreProductLogic extends BaseLogic
'store_id' => $store_id,
'sales' => 0,
'stock' => $stock,
'manufacturer_information' => $find['manufacturer_information']??'',
];
StoreBranchProduct::create($product);
$arr = [

View File

@ -23,6 +23,7 @@ use app\common\model\store_order\StoreOrder;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
use app\common\model\user\UserRecharge;
use app\common\model\user_create_log\UserCreateLog;
use app\common\model\user_label\UserLabel;
use app\common\model\user_sign\UserSign;
use app\common\model\vip_flow\VipFlow;
@ -90,9 +91,16 @@ class UserLogic extends BaseLogic
'password' => $password,
'mobile' => $params['mobile'],
'user_ship' => $params['user_ship']??0,
'label_id' => $params['label_id']??0,
];
$res=User::create($data);
UserCreateLog::create([
'uid' => $res['id'],
'create_uid' => $params['create_uid']??0,
'store_id' => $params['store_id']??0,
'staff_id' => $params['staff_id']??0,
]);
UserAddress::create([
'uid' => $res['id'],
'real_name' => $params['real_name']??"",
@ -190,12 +198,13 @@ class UserLogic extends BaseLogic
switch ($params['type']){
case 1:
//采购款明细
$categories = ['user_balance_recharge', 'user_order_purchase_pay'];
$categories = ['user_balance_recharge', 'user_order_purchase_pay','system_purchase_add'];
$query = CapitalFlow::where('uid', $params['id'])
->whereIn('category', $categories);
$count = $query->count();
$data = $query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
foreach ($data as &$value){
if($value['category'] == 'user_order_purchase_pay'){
@ -207,11 +216,13 @@ class UserLogic extends BaseLogic
break;
case 2:
//余额明细
$category = ['system_balance_add','user_order_balance_pay'];
$query = CapitalFlow::where('uid', $params['id'])
->where('category', 'user_order_balance_pay');
->whereIn('category', $category);
$count = $query->count();
$data = $query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
foreach ($data as &$value){
$value['order_sn'] = StoreOrder::where('id',$value['link_id'])->value('order_id');
@ -224,6 +235,7 @@ class UserLogic extends BaseLogic
$count = $query->count();
$data =$query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
break;
case 4:
@ -232,6 +244,7 @@ class UserLogic extends BaseLogic
$count = $query->count();
$data = $query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
break;
default:

View File

@ -20,6 +20,7 @@ class StoreOrderValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require',
'order_id' => 'require',
];
@ -29,8 +30,17 @@ class StoreOrderValidate extends BaseValidate
*/
protected $field = [
'id' => 'id',
'order_id' => '订单编号',
];
/**
* @return StoreOrderValidate
*/
public function sceneRefund()
{
return $this->only(['order_id']);
}
/**
* @notes 添加场景

View File

@ -0,0 +1,138 @@
<?php
namespace app\api\controller;
use app\common\model\finance\CapitalFlow;
use app\common\model\user\User;
use app\common\model\vip_flow\VipFlow;
class BackController extends BaseApiController
{
public $notNeedLogin = ['backProfit'];
/**
* 返利
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function backProfit()
{
//读取前3天的值 按照用户id和类型分下 加到对应的钱
$startTime = strtotime(date('Y-m-d', strtotime('-3 days')));
$endTime = strtotime(date('Y-m-d'));
$result = VipFlow::where('create_time', '>=', $startTime)
->where('create_time', '<', $endTime)
->group('user_id, pay_type')
->field('user_id, pay_type, COUNT(*) as transaction_count, SUM(number) as total_amount')
->select()->toArray();
// 遍历查询结果并分类 现金不进入反的逻辑
//3余额 18采购款 7微信小程序 9微信条码 13 支付宝条码支付
$Balance = [];
$Procurement = [];
$WechatMiniPay = [];
$WechatBarcodePay = [];
$AliBarcodePay = [];
foreach ($result as $row) {
$payType = $row['pay_type'];
$userId = $row['user_id'];
$totalAmount = $row['total_amount'];
switch ($payType) {
case 3:
$user_now_money = User::where(
[
'id' => $userId
]
)->withTrashed()->value('now_money');
$Balance[] = [
'id' => $userId,
'now_money' => bcadd($user_now_money, $totalAmount, 2),
];
break;
case 7:
$WechatMiniPay[] = [
'id' => $userId,
'total_amount' => $totalAmount,
];
break;
case 9:
$WechatBarcodePay[] = [
'id' => $userId,
'total_amount' => $totalAmount,
];
break;
case 13:
$AliBarcodePay[] = [
'id' => $userId,
'total_amount' => $totalAmount,
];
break;
case 18:
$purchase_funds_money = User::where(
[
'id' => $userId
]
)->withTrashed()->value('purchase_funds');
$Procurement[] = [
'id' => $userId,
'purchase_funds' => bcadd($purchase_funds_money, $totalAmount, 2),
];
break;
}
}
//入记录表的话查询后便利入 3余额 18采购款
if ($Balance) {
(new User())->saveAll($Balance);
$this->dealCapital($startTime, $endTime, 3);
}
if ($Procurement) {
(new User())->saveAll($Procurement);
$this->dealCapital($startTime, $endTime, 18);
}
//7微信小程序 9微信条码 13 支付宝条码支付
}
public function dealCapital($startTime, $endTime, $pay_type)
{
$vipFrozen = VipFlow::where('create_time', '>=', $startTime)
->where('create_time', '<', $endTime)
->where('pay_type', $pay_type)->select()->toArray();
if ($pay_type == 18) {
$category_title = 'system_purchase_add';
$title = '系统增加采购款';
$mark = '系统增加采购款';
$filed = 'purchase_funds';
} else {
$category_title = 'system_balance_add';
$title = '系统增加余额';
$mark = '系统反余额冻结';
$filed = 'now_money';
}
$newArr = [];
foreach ($vipFrozen as $k => $value) {
$user_funds = User::where('id', $value['user_id'])->value($filed);
$newArr[$k]['uid'] = $value['user_id'];
$newArr[$k]['category'] = $category_title;
$newArr[$k]['link_type'] = 'order';
$newArr[$k]['link_id'] = $value['order_id'];
$newArr[$k]['amount'] = $value['number'];
$newArr[$k]['before_balance'] = $user_funds;
$newArr[$k]['balance'] = bcadd($user_funds, $value['number'], 2);
$newArr[$k]['create_time'] = date('Y-m-d H:i:s');
$newArr[$k]['type'] = 'in';
$newArr[$k]['title'] = $title . "{$value['number']}";
$newArr[$k]['mark'] = $mark;
}
(new CapitalFlow())->saveAll($newArr);
}
}

View File

@ -6,6 +6,7 @@ use app\admin\logic\store_product\StoreProductLogic;
use app\admin\validate\tools\GenerateTableValidate;
use app\admin\logic\tools\GeneratorLogic;
use app\common\logic\store_order\StoreOrderLogic;
use app\common\model\Config as ModelConfig;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\system_store\SystemStore;
use app\common\service\pay\PayService;
@ -27,38 +28,17 @@ class IndexController extends BaseApiController
public function index()
{
$arr = StoreBranchProduct::select();
foreach ($arr as $item) {
StoreProductLogic::updateGoodsclass($item['cate_id'], $item['store_id']);
}
d(1);
$order = [
'out_trade_no' => 'CZ1719197818549414',
];
$app = new PayService(0);
try {
$wechat = new PayService(1);
$time = time();
$order = [
'out_trade_no' => 'PF1717558027664507',
'out_refund_no' => 'BO' . $time,
'amount' => [
'refund' => 1,
'total' => 1,
'currency' => 'CNY',
],
// '_action' => 'jsapi', // jsapi 退款,默认
// '_action' => 'app', // app 退款
// '_action' => 'combine', // 合单退款
// '_action' => 'h5', // h5 退款
// '_action' => 'miniapp', // 小程序退款
// '_action' => 'native', // native 退款
];
$res = $wechat->wechat->refund($order);
Cache::set('kk', json_decode($res, true));
} catch (Exception $e) {
\support\Log::info($e->extra['message'] ?? $e->getMessage());
throw new \Exception($e->extra['message'] ?? $e->getMessage());
$res = $app->wechat->query($order);
} catch (\Exception $e) {
return $this->fail($e->extra['message']);
}
d(1);
d($res);

View File

@ -17,8 +17,7 @@ class LoginController extends BaseApiController
*/
public function account()
{
$params=$this->request->post();
// $params = (new LoginAccountValidate())->post()->goCheck();
$params = (new LoginAccountValidate())->post()->goCheck();
$result = LoginLogic::login($params);
if (false === $result) {
return $this->fail(LoginLogic::getError());
@ -79,8 +78,11 @@ class LoginController extends BaseApiController
public function updateUser()
{
$params = (new WechatLoginValidate())->post()->goCheck("updateUser");
LoginLogic::updateUser($params, $this->userId);
return $this->success('操作成功', [], 1, 1);
$result = LoginLogic::updateUser($params, $this->userId);
if ($result === false) {
return $this->fail(LoginLogic::getError());
}
return $this->success('操作成功', [], 1, 0);
}
/**

View File

@ -19,7 +19,7 @@ use support\Log;
class PayController extends BaseApiController
{
public $notNeedLogin = ['notifyMnp', 'alipay_return', 'alipay_notify'];
public $notNeedLogin = ['notifyMnp', 'alipay_return', 'alipay_notify', 'wechatQuery'];
/**
* @notes 小程序支付回调
@ -44,19 +44,18 @@ class PayController extends BaseApiController
break;
}
}
}else{
} else {
if ($result && $result->event_type == 'REFUND.SUCCESS') {
$ciphertext = $result->resource['ciphertext'];
if ($ciphertext['refund_status'] === 'SUCCESS') {
//处理订单 -1判断是退的一单还是拆分的订单
$out_trade_no = $ciphertext['out_trade_no'].'-1';
$check = StoreOrder::where('order_id',$out_trade_no)->count();
if($check){
$ciphertext['out_trade_no'] =$out_trade_no;
$out_trade_no = $ciphertext['out_trade_no'] . '-1';
$check = StoreOrder::where('order_id', $out_trade_no)->count();
if ($check) {
$ciphertext['out_trade_no'] = $out_trade_no;
}
PayNotifyLogic::handle('refund', $ciphertext['out_trade_no'], $ciphertext);
$app->wechat->success();
}
}
}
@ -68,17 +67,21 @@ class PayController extends BaseApiController
public function wechatQuery()
{
$order_no = $this->request->get('order_no');
$recharge = $this->request->get('recharge',0);
$recharge = $this->request->get('recharge', 0);
$order = [
'out_trade_no' => $order_no,
];
$app = new PayService(0);
$res = $app->wechat->query($order);
try {
$res = $app->wechat->query($order);
} catch (\Exception $e) {
return $this->fail($e->extra['message']);
}
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
if($recharge==0){
if ($recharge == 0) {
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
}else{
} else {
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
}
return $this->success('支付成功');
@ -97,7 +100,7 @@ class PayController extends BaseApiController
if ($result) {
$data = $result->toArray();
if ($data['trade_status'] === 'TRADE_SUCCESS') {
$attach = $data['extend_params']['attach']??'';
$attach = $data['extend_params']['attach'] ?? '';
switch ($attach) {
case 'alipay_cashier':
PayNotifyLogic::handle('alipay_cashier', $data['out_trade_no'], $data);
@ -117,7 +120,7 @@ class PayController extends BaseApiController
if ($result) {
$data = $result->toArray();
if ($data['trade_status'] === 'TRADE_SUCCESS') {
$attach = $data['extend_params']['attach']??'';
$attach = $data['extend_params']['attach'] ?? '';
switch ($attach) {
case 'alipay_cashier':
PayNotifyLogic::handle('alipay_cashier', $data['out_trade_no'], $data);

View File

@ -30,15 +30,9 @@ class OrderController extends BaseApiController
return $this->dataLists(new OrderList());
}
// #[
// ApiDoc\Title('核销码查数据'),
// ApiDoc\url('/api/order/order/write_code'),
// ApiDoc\Method('POST'),
// ApiDoc\Param(name: "code", type: "string", require: false, desc: "核销码"),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
/**
* 核销码查数据
*/
public function write_code()
{
$code = $this->request->post('code');
@ -52,18 +46,9 @@ class OrderController extends BaseApiController
return $this->success('ok', $res);
}
// #[
// ApiDoc\Title('核销订单列表'),
// ApiDoc\url('/api/order/order/write_list'),
// ApiDoc\Method('POST'),
// ApiDoc\Param(name: "status", type: "int", require: true, desc: "1待核销2已核销"),
// ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"),
// ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"),
// ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
/**
* 核销订单列表
*/
public function write_list()
{
$status = (int)$this->request->post('status', 1);
@ -81,15 +66,9 @@ class OrderController extends BaseApiController
return $this->success('ok', $res);
}
// #[
// ApiDoc\Title('核销数量'),
// ApiDoc\url('/api/order/order/write_count'),
// ApiDoc\Method('POST'),
// ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
/**
* 核销数量
*/
public function write_count()
{
$info = $this->userInfo;
@ -98,41 +77,9 @@ class OrderController extends BaseApiController
return $this->success('ok', $res);
}
// #[
// ApiDoc\Title('订单校验'),
// ApiDoc\url('/api/order/order/checkOrder'),
// ApiDoc\Method('POST'),
// ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "购物车id"),
// ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"),
// ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"),
// ApiDoc\Param(name: "verify_code", type: "int", require: true, desc: "校验码"),
// ApiDoc\Param(name: "shipping_type", type: "int", require: true, desc: "配送方式"),
// ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array", children: [
// ['name' => 'order', 'desc' => '订单信息', 'type' => 'array', 'children' => [
// ['name' => 'create_time', 'desc' => '订单创建时间', 'type' => 'int'],
// ['name' => 'order_id', 'desc' => '订单id', 'type' => 'int'],
// ['name' => 'total_price', 'desc' => '订单总金额', 'type' => 'float'],
// ['name' => 'pay_price', 'desc' => '实际支付金额', 'type' => 'float'],
// ['name' => 'total_num', 'desc' => '订单总数量', 'type' => 'int'],
// ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'int'],
// ['name' => 'cart_id', 'desc' => '购物车id', 'type' => 'string'],
// ['name' => 'store_id', 'desc' => '店铺id', 'type' => 'int'],
// ['name' => 'shipping_type', 'desc' => '配送方式', 'type' => 'int'],
// ]],
// ['name' => 'cart_list', 'desc' => '购物车商品列表', 'type' => 'array', 'children' => [
// ['name' => 'goods', 'desc' => '商品id', 'type' => 'int'],
// ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'int'],
// ['name' => 'total', 'desc' => '商品总价', 'type' => 'float'],
// ['name' => 'price', 'desc' => '商品单价', 'type' => 'float'],
// ['name' => 'product_id', 'desc' => '商品id', 'type' => 'int'],
// ['name' => 'old_cart_id', 'desc' => '原购物车id', 'type' => 'string'],
// ['name' => 'verify_code', 'desc' => '校验码', 'type' => 'string'],
// ]],
// ]),
// ]
/**
* 订单校验
*/
public function checkOrder()
{
$cartId = (array)$this->request->post('cart_id', []);
@ -140,7 +87,7 @@ class OrderController extends BaseApiController
// $pay_type = (int)$this->request->post('pay_type');
// $auth_code = $this->request->post('auth_code'); //微信支付条码
$params = $this->request->post();
$user=User::where('id',$this->userId)->find();
$user = User::where('id', $this->userId)->find();
$res = OrderLogic::cartIdByOrderInfo($cartId, $addressId, $user, $params);
if ($res == false) {
$msg = OrderLogic::getError();
@ -152,19 +99,9 @@ class OrderController extends BaseApiController
return $this->data($res);
}
// #[
// ApiDoc\Title('创建订单'),
// ApiDoc\url('/api/order/order/createOrder'),
// ApiDoc\Method('POST'),
// ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "id"),
// ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"),
// ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"),
// ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"),
// ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
/**
* 创建订单
*/
public function createOrder()
{
$cartId = (array)$this->request->post('cart_id', []);
@ -180,12 +117,23 @@ class OrderController extends BaseApiController
return $this->fail('购物车商品不能超过100个');
}
$user=User::where('id',$this->userId)->find();
$user = User::where('id', $this->userId)->find();
if ($pay_type == PayEnum::PURCHASE_FUNDS || $pay_type == PayEnum::BALANCE_PAY) {
if (!isset($params['password'])) {
return $this->fail('缺失参数');
}
if (empty($user['pay_password'])) {
return $this->fail('请设置密码');
}
if (!password_verify($params['password'], $user['pay_password'])) {
return $this->fail('密码错误');
}
}
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
if ($order != false) {
if($order['pay_price'] <= 0){
if ($order['pay_price'] <= 0) {
$pay_type = 3;
}
switch ($pay_type) {
@ -266,18 +214,9 @@ class OrderController extends BaseApiController
return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving, 'all' => $all, 'applyRefund' => $applyRefund, 'refund' => $refund]);
}
// #[
// ApiDoc\Title('订单支付'),
// ApiDoc\url('/api/order/order/pay'),
// ApiDoc\Method('POST'),
// ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"),
// ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"),
// ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"),
// ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
// ApiDoc\NotHeaders(),
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
// ApiDoc\ResponseSuccess("data", type: "array"),
// ]
/**
* 订单支付
*/
public function pay()
{
$order_id = (int)$this->request->post('order_id');
@ -366,18 +305,18 @@ class OrderController extends BaseApiController
public function detail()
{
$order_id = (int)$this->request->get('order_id');
$lat = $this->request->get('lat','');
$lng = $this->request->get('long','');
$lat = $this->request->get('lat', '');
$lng = $this->request->get('long', '');
$where = [
'id' => $order_id,
'uid' => $this->userId,
];
$url = 'https://'.$this->request->host(true);
$url = 'https://' . $this->request->host(true);
$parm = [
'lat'=>$lat,
'long'=>$lng
'lat' => $lat,
'long' => $lng
];
$order = OrderLogic::detail($where,$url,$parm);
$order = OrderLogic::detail($where, $url, $parm);
if ($order) {
return $this->data($order);
} else {

View File

@ -5,6 +5,7 @@ namespace app\api\controller\store;
use app\admin\logic\user\UserLogic as UserUserLogic;
use app\api\lists\store\SystemStoreLists;
use app\api\controller\BaseApiController;
use app\api\lists\user_create_log\UserCreateLogLists;
use app\api\logic\store\StoreLogic;
use app\api\logic\user\UserLogic;
use app\api\validate\UserValidate;
@ -12,6 +13,7 @@ use app\common\enum\PayEnum;
use app\common\logic\PaymentLogic;
use app\common\logic\PayNotifyLogic;
use app\common\model\user\User;
use app\common\model\user_create_log\UserCreateLog;
use app\common\model\user_recharge\UserRecharge;
use Webman\RedisQueue\Redis;
@ -23,6 +25,13 @@ class StoreController extends BaseApiController
return $this->dataLists(new SystemStoreLists());
}
/**
* 创建用户记录列表
*/
public function create_lists()
{
return $this->dataLists(new UserCreateLogLists());
}
/**
* 门店信息
@ -54,19 +63,24 @@ class StoreController extends BaseApiController
{
$params = (new UserValidate())->post()->goCheck('rechargeStoreMoney');
$auth_code = $this->request->post('auth_code'); //微信支付条码
$recharge_type = $this->request->post('recharge_type',''); //微信支付条码
$find=User::where('mobile',$params['mobile'])->find();
if(!$find){
$params['create_uid']=$this->userId;
$find=UserUserLogic::StoreAdd($params);
}else{
$find['real_name']=$params['real_name'];
$find->save();
}
if($recharge_type!='INDUSTRYMEMBERS'){
return $this->success('添加用户成功');
}
$data=[
'store_id'=>$params['store_id'],
'uid'=>$find['id'],
'staff_id'=>0,
'order_id'=>getNewOrderId('CZ'),
'price'=>0.01,
'price'=>1000,
'recharge_type'=>'INDUSTRYMEMBERS',
];
$order = UserRecharge::create($data);
@ -92,10 +106,12 @@ class StoreController extends BaseApiController
{
$store_id = $this->request->get('store_id',0);
$count=0;
$createLog=0;
if($store_id){
$count= UserRecharge::where(['store_id'=>$store_id,'recharge_type'=>'INDUSTRYMEMBERS','paid'=>1])->count();
$createLog= UserCreateLog::where(['store_id'=>$store_id])->count();
}
return $this->success('ok',['count'=>$count]);
return $this->success('ok',['count'=>$count,'create_log'=>$createLog]);
}
}

View File

@ -7,6 +7,8 @@ use app\api\logic\user\UserLogic;
use app\api\validate\UserValidate;
use app\common\enum\PayEnum;
use app\common\logic\PaymentLogic;
use support\Cache;
use think\Exception;
/**
@ -16,6 +18,7 @@ use app\common\logic\PaymentLogic;
*/
class UserController extends BaseApiController
{
public $notNeedLogin = ['login_sms'];
// #[
// ApiDoc\Title('获取小程序手机号'),
// ApiDoc\url('/api/user/user/getMobileByMnp'),
@ -133,4 +136,83 @@ class UserController extends BaseApiController
return $this->success('ok',$res);
}
public function send_sms()
{
$res = (new UserLogic())->dealSendSms($this->userId);
if ($res){
return $this->success('发送成功');
}
return $this->fail('发送失败');
}
public function login_sms()
{
$params = (new UserValidate())->post()->goCheck('login');
$res = (new UserLogic())->dealLoginSms($params['account']);
if ($res){
return $this->success('发送成功');
}
return $this->fail('发送失败');
}
public function set_payPassword()
{
$params = (new UserValidate())->post()->goCheck('setPayPassword');
$remark = $this->userId.'_payPassword';
$code = Cache::get($remark);
if ($code && isset($params['code']) && $code !== $params['code']) {
throw new Exception('验证码错误');
}
if ($params['rePassword'] !== $params['password'])
return $this->fail('两次密码不一致');
$result = UserLogic::dealPayPassword($params,$this->userId);
if (!$result) {
return $this->fail('设置失败');
}
return $this->success('设置成功');
}
//修改
// public function withdrawalPassword()
// {
// $data = $this->request->params(['repassword', 'password', 'sms_code']);
// $sms_code = app()->make(SmsService::class)->checkSmsCode($this->user->phone, $data['sms_code'], 'change_pwd');
// if (!$data['sms_code'] || !$sms_code) {
// return app('json')->fail('验证码不正确');
// }
// if (!$this->user->phone)
// return app('json')->fail('请先绑定手机号');
// if (empty($data['repassword']) || empty($data['password']))
// return app('json')->fail('请输入提现密码');
// if ($data['repassword'] !== $data['password'])
// return app('json')->fail('两次密码不一致');
// $password = $this->repository->encodePassword($data['password']);
// $this->repository->update($this->request->uid(), ['withdrawal_pwd' => $password]);
// return app('json')->success('绑定成功');
//
// }
//采购款明细、余额明细、礼品券明细、返还金明细
public function fundList()
{
(new UserValidate())->get()->goCheck('fund');
$page_no = (int)$this->request->get('page_no', 1);
$page_size = (int)$this->request->get('page_size', 15);
$params = $this->request->get();
$params['page_no'] = $page_no > 0 ? $page_no : 1;
$params['page_size'] = $page_size > 0 ? $page_size : 15;
$res = UserLogic::dealDetails($params,$this->userId);
$res['page_no'] = $params['page_no'];
$res['page_size'] = $params['page_size'];
return $this->success('ok', $res);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace app\api\controller\user_label;
use app\api\controller\BaseApiController;
use app\admin\lists\user_label\UserLabelLists;
/**
* 用户标签控制器
* Class UserLabelController
* @package app\admin\controller\user_label
*/
class UserLabelController extends BaseApiController
{
/**
* @notes 获取用户标签列表
* @return \think\response\Json
* @author admin
* @date 2024/06/17 17:02
*/
public function lists()
{
$this->request->__set('id',1);
return $this->dataLists(new UserLabelLists());
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace app\api\controller\user_ship;
use app\api\controller\BaseApiController;
use app\common\lists\user\UserShipLists;
/**
* 用户类型控制器
* Class UserLabelController
* @package app\admin\controller\user_label
*/
class UserShipController extends BaseApiController
{
/**
* @notes 获取用户类型列表
* @return \think\response\Json
* @author admin
* @date 2024/06/17 17:02
*/
public function lists()
{
$this->request->__set('id',1);
return $this->dataLists(new UserShipLists());
}
}

View File

@ -11,6 +11,7 @@ use app\common\model\dict\DictType;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_product_attr_value\StoreProductAttrValue;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\user\User;
/**
* 购物车列表
@ -21,6 +22,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
{
protected $total_price = 0;
protected $activity_price = 0;
/**
@ -59,17 +61,26 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
})
->toArray();
// $check = DictType::where('type', 'activities')->find();
$user = User::where('id', $userId)->find();
foreach ($list as $key => &$item) {
$find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']])
->field('product_id,image,price,cost,store_name,unit,delete_time')
->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price')
->withTrashed()
->find();
// if (isset($check) && $check['status'] == 1) {
// $find['price'] = $find['cost'];
// }
if ($find) {
if ($user && $user['user_ship'] == 1) {
//更新 会员为1的时候原价减去会员价
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2);
$this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2);
}elseif ($user && $user['user_ship'] == 4) {
//更新 为4商户的时候减去商户价格
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2);
$this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2);
}else{
$this->activity_price =0;
}
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
$item['imgs'] = $find['image'];
@ -100,6 +111,10 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
public function extend()
{
return ['total_price' => $this->total_price];
return [
'total_price' => $this->total_price,
'activity_price' => $this->activity_price,
'pay_price'=> bcsub($this->total_price, $this->activity_price, 2)
];
}
}

View File

@ -6,6 +6,7 @@
use app\common\lists\ListsSearchInterface;
use app\common\model\user\User;
use app\common\model\user\UserFeedback;
use app\common\model\user_label\UserLabel;
use app\common\model\user_recharge\UserRecharge;
//用户充值表
@ -42,7 +43,17 @@ use app\common\model\user_recharge\UserRecharge;
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$data['real_name'] =User::where('id',$data['uid'])->value('real_name');
$data['label_name']='';
if($data['recharge_type']=='INDUSTRYMEMBERS'){
$find =User::where('id',$data['uid'])->find();
$data['real_name']=$find['real_name']??'';
if($find &&$find['label_id']>0){
$data['label_name']=UserLabel::where('label_id',$find['label_id'])->value('label_name');
}
}else{
$data['real_name'] =User::where('id',$data['uid'])->value('real_name');
}
return $data;
})
->toArray();
}

View File

@ -0,0 +1,70 @@
<?php
namespace app\api\lists\user_create_log;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\system_store\SystemStore;
use app\common\lists\ListsSearchInterface;
use app\common\model\user\User;
use app\common\model\user_create_log\UserCreateLog;
/**
* 用户前端添加记录列表
* Class UserCreateLogLists
* @package app\admin\listssystem_store
*/
class UserCreateLogLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/05/31 17:45
*/
public function setSearch(): array
{
return [
'=' => ['store_id'],
];
}
/**
* @notes 获取用户前端添加记录列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/05/31 17:45
*/
public function lists(): array
{
$data = UserCreateLog::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item){
$item['system_store_name'] = SystemStore::where('id',$item['store_id'])->value('name');
$item['nickname'] = User::where('id',$item['uid'])->value('real_name');
$item['create_nickname'] = User::where('id',$item['create_uid'])->value('real_name');
})
->toArray();
return $data;
}
/**
* @notes 获取用户前端添加记录数量
* @return int
* @author admin
* @date 2024/05/31 17:45
*/
public function count(): int
{
return UserCreateLog::where($this->searchWhere)->count();
}
}

View File

@ -435,12 +435,22 @@ class LoginLogic extends BaseLogic
* @notes 更新用户信息
* @param $params
* @param $userId
* @return User
* @return User|bool
* @author 段誉
* @date 2023/2/22 11:19
*/
public static function updateUser($params, $userId)
{
$find=User::where(['mobile' =>$params['mobile']])->find();
if($find){
$auth=UserAuth::where(['user_id'=>$find['id']])->find();//别人的
if($auth){
self::$error ='该手机号已绑定';
return false;
}else{
UserAuth::where(['user_id'=>$userId])->update(['user_id'=>$find['id']]);
}
}
$data=[
'mobile'=>$params['mobile'],
'is_new_user' => YesNoEnum::NO

View File

@ -129,16 +129,18 @@ class OrderLogic extends BaseLogic
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格
// self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
}
if ($user && $user['user_ship'] == 1) {
//加支付方式限制
$pay_type = isset($params['pay_type'])?$params['pay_type']:0;
if ($user && $user['user_ship'] == 1 && $pay_type !=17) {
$pay_price = self::$pay_price;
}else{
$pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
}
if($pay_price < 500){
throw new Exception('金额低于500');
}
$vipPrice = 0;
// if($pay_price < 500){
// throw new Exception('金额低于500');
// }
//成本价 收益
$order = [
'create_time' => time(),
@ -147,7 +149,7 @@ class OrderLogic extends BaseLogic
'cost' => self::$cost, //成本价1-
'profit' =>0, //利润
'pay_price' => $pay_price, //后期可能有降价抵扣
'vip_price' => $vipPrice,
'vip_price' => 0,
'total_num' => count($cart_select), //总数
'pay_type' => $params['pay_type'] ?? 0,
'reservation_time' => $params['reservation_time'] ?? null,
@ -224,24 +226,17 @@ class OrderLogic extends BaseLogic
try {
$order = StoreOrder::create($_order);
$goods_list = $orderInfo['cart_list'];
$updateData = [];
foreach ($goods_list as $k => $v) {
$goods_list[$k]['oid'] = $order->id;
$goods_list[$k]['uid'] = $user['id'];
$goods_list[$k]['cart_id'] = implode(',', $cartId);
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
$StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find();
$updateData[] = [
'id' => $v['branch_product_id'],
'stock' => $StoreBranchProduct['stock']-$v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
if($StoreBranchProduct['stock']-$v['cart_num']<=0){
Db::name('store_product_cate')->where(['cate_id'=>$StoreBranchProduct['cate_id'],'store_id'=>$params['store_id']])->update(['count'=>0]);
}
}
(new StoreOrderCartInfo())->saveAll($goods_list);
(new StoreBranchProduct())->saveAll($updateData);
$where = ['is_pay' => 0];
Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]);
Db::commit();
@ -404,7 +399,6 @@ class OrderLogic extends BaseLogic
//核销
/**
* @param $params
* @return bool
@ -447,6 +441,51 @@ class OrderLogic extends BaseLogic
// }
$order=StoreOrder::where('id',$data['id'])->find();
PayNotifyLogic::afterPay($order);
PayNotifyLogic::descStock($order['id']);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
d($e);
self::setError($e->getMessage());
return false;
}
}
//不走二次分钱的核销
public static function lessWriteOff($params): bool
{
$data = StoreOrder::with('store')->where([
'verify_code' => $params['verify_code']
])->find();
if (empty($data)) {
return false;
}
Db::startTrans();
try {
StoreOrder::update([
'verify_code'=>$params['verify_code'].'-1',
'status' => OrderEnum::RECEIVED_GOODS,
'is_writeoff' => OrderEnum::IS_OK,
'update_time' => time(),
'store_id' => $params['store_id'],
'staff_id' => $params['staff_id']??0,
], ['id' => $data['id']]);
(new StoreOrderCartInfo())->update([
'verify_code'=>$params['verify_code'].'-1',
'writeoff_time' => time(),
'is_writeoff' => YesNoEnum::YES,
'store_id' => $params['store_id'],
'staff_id' => $params['staff_id']??0,
'update_time' => time(),
], ['oid' => $data['id']]);
// $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']);
// if (!empty($financeFlow)) {
// $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store');
// $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']);
// }
$order=StoreOrder::where('id',$data['id'])->find();
PayNotifyLogic::descSwap($order['id']);
Db::commit();
return true;
} catch (\Exception $e) {
@ -457,6 +496,8 @@ class OrderLogic extends BaseLogic
}
public static function write_count($info, $params)
{
$store_id = SystemStoreStaff::where('phone', $info['mobile'])->value('store_id');

View File

@ -107,6 +107,6 @@ class AddressLogic extends BaseLogic
*/
public static function detail($params): array
{
return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where($params)->findOrEmpty()->toArray();
return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray();
}
}

View File

@ -12,9 +12,14 @@ use app\common\{logic\BaseLogic,
model\system_store\SystemStore,
model\system_store\SystemStoreStaff,
model\user\User,
model\user\UserAuth,
model\user\UserRecharge,
model\user\UserShip,
model\user_sign\UserSign,
model\vip_flow\VipFlow,
service\SmsService,
service\wechat\WeChatMnpService};
use support\Cache;
use think\facade\Db;
@ -70,7 +75,7 @@ class UserLogic extends BaseLogic
{
$data = User::with(['userShip'])->where('id',$uid)
->field('id,avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship
,purchase_funds,integral')
,purchase_funds,integral,pay_password')
->find();
//判断是不是员工
if($data){
@ -95,7 +100,11 @@ class UserLogic extends BaseLogic
$data['return_money'] = Db::name('vip_flow')->
where(['user_id'=>$uid,'status'=>0])
->sum('number');
//小程序 未核销的订单
$data['no_writeoff'] = StoreOrder::where([
'is_writeoff'=>0,'uid'=>$uid
])->whereIn('shipping_type',[1,2])->count();
$data['openid'] = UserAuth::where(['user_id'=>$uid,'terminal'=>1])->value('openid');
}else{
$data = [];
}
@ -164,5 +173,143 @@ class UserLogic extends BaseLogic
->select()->toArray();
}
public function dealSendSms($uid)
{
$code = generateRandomCode();
$phone = User::where('id',$uid)->value('mobile');
if(empty($phone)){
throw new \Exception('用户未设置手机号');
}
$template = getenv('SMS_TEMPLATE');
$check =(new SmsService())->client($phone,$template,$code);
if($check){
$remark = $uid.'_payPassword';
Cache::set($remark,$code,5*60);
return true;
}else{
return false;
}
}
public function dealLoginSms($phone)
{
$code = generateRandomCode();
$template = getenv('SMS_LOGIN_TEMPLATE');
$check =(new SmsService())->client($phone,$template,$code);
if($check){
$remark = $phone.'_login';
Cache::set($remark,$code,5*60);
return true;
}else{
return false;
}
}
public static function dealPayPassword($params,$uid)
{
$password = payPassword($params['password']);
return User::where('id',$uid)
->update(['pay_password'=>$password]);
}
public static function dealDetails($params,$uid)
{
switch ($params['type']){
case 1:
//采购款明细
$categories = ['user_balance_recharge', 'user_order_purchase_pay','system_purchase_add'];
$query = CapitalFlow::where('uid', $uid)
->whereIn('category', $categories);
if($params['mark'] == 1){
$query->where('type','in');
}
if($params['mark'] == 2){
$query->where('type','out');
}
$count = $query->count();
$data = $query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
foreach ($data as &$value){
if($value['category'] == 'user_order_purchase_pay' || $value['category'] == 'system_purchase_add' ){
$value['order_sn'] = StoreOrder::where('id',$value['link_id'])->value('order_id');
}elseif($value['category'] == 'user_balance_recharge'){
$value['order_sn'] = UserRecharge::where('id',$value['link_id'])->value('order_id');
}
}
break;
case 2:
//余额明细
$category = ['system_balance_add','user_order_balance_pay'];
$query = CapitalFlow::where('uid', $uid)
->whereIn('category', $category);
if($params['mark'] == 1){
$query->where('type','in');
}
if($params['mark'] == 2){
$query->where('type','out');
}
$count = $query->count();
$data = $query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
foreach ($data as &$value){
$value['order_sn'] = StoreOrder::where('id',$value['link_id'])->value('order_id');
}
break;
case 3:
//礼品券明细
$query = UserSign::where(['uid'=>$uid]);
if($params['mark'] == 1){
$query->where('financial_pm',1);
}
if($params['mark'] == 2){
$query->where('financial_pm',0);
}
$count = $query->count();
$data =$query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
break;
case 4:
//返还金明细 -todo back
$query = VipFlow::with('store')->where(['user_id'=>$uid]);
if($params['mark'] == 1){
$query->where('status',1);
}
if($params['mark'] == 2){
$query->where('status',0);
}
$count = $query->count();
$data = $query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
break;
default:
$data = [];
$count = 0;
}
return [
'lists' => $data,
'count' => $count
];
}
}

View File

@ -5,12 +5,15 @@ namespace app\api\validate;
use app\common\cache\UserAccountSafeCache;
use app\common\enum\LoginEnum;
use app\common\enum\notice\NoticeEnum;
use app\common\enum\PayEnum;
use app\common\enum\user\UserTerminalEnum;
use app\common\enum\YesNoEnum;
use app\common\service\ConfigService;
use app\common\service\sms\SmsDriver;
use app\common\validate\BaseValidate;
use app\common\model\user\User;
use support\Cache;
use think\Exception;
use Webman\Config;
/**
* 账号密码登录校验
@ -138,10 +141,23 @@ class LoginAccountValidate extends BaseValidate
*/
public function checkCode($code, $rule, $data)
{
$remark = $data['account'].'_login';
if($data['code'] == '8888'){
return true;
}
$code = Cache::get($remark);
if(empty($code)){
return '验证码不存在';
}
if (isset($data['code']) && $code != $data['code']) {
return '验证码错误';
}
return true;
// $smsDriver = new SmsDriver();
// $result = $smsDriver->verify($data['account'], $code, NoticeEnum::LOGIN_CAPTCHA);
// if ($result) {
// return true;
// return true;
// }
// return '验证码错误';
}

View File

@ -18,15 +18,44 @@ class UserValidate extends BaseValidate
'code' => 'require',
'store_id' => 'require',
'mobile' => 'require',
'phone' => 'require|number',
'password' => 'require',
'rePassword' => 'require',
'type' => 'require',
'account' => 'require',
];
protected $message = [
'code.require' => '参数缺失',
'store_id.require' => '门店id',
'mobile.require' => '手机',
'phone.require' => '手机',
'account.require' => '手机',
'password.require' => '密码',
'rePassword.require' => '确认密码',
'type' => '查询类型',
];
public function sceneLogin()
{
return $this->only(['account']);
}
public function sceneFund()
{
return $this->only(['type']);
}
//设置/更新密码
public function sceneSetPayPassword()
{
return $this->only(['code','password','rePassword']);
}
/**
* @notes 获取小程序手机号场景
* @return UserValidate

View File

@ -62,6 +62,11 @@ class OrderEnum
*/
const RECEIVED_GOODS = 2;
/**
* @RECEIVED_BACK 已退款
*/
const RECEIVED_BACK = 4;
/**
* @WAIT_EVALUATION 待评价
*/
@ -184,6 +189,7 @@ class OrderEnum
self::WAIT_RECEIVING => '待收货',
self::RETURN_SUCCESS => '退货成功',
self::ALREADY_REFUND => '已退款',
self::RECEIVED_BACK => '已退款',
];
if ($value === true) {
return $data;

View File

@ -32,6 +32,7 @@ class PayEnum
* @CORPORATE_TRANSFER 对公转账
* @CASH_PAY 现金支付
* @PURCHASE_FUNDS 采购款收银
* @GIFT_FUNDS 礼品券收银
*/
const BALANCE_PAY = 3;
const WECHAT_PAY = 1;
@ -51,6 +52,7 @@ class PayEnum
const CORPORATE_TRANSFER = 16;
const CASH_PAY = 17;
const PURCHASE_FUNDS = 18;//采购款收银
const GIFT_FUNDS = 19;//礼品券收银
//支付状态
const UNPAID = 0; //未支付
const ISPAID = 1; //已支付
@ -101,6 +103,7 @@ class PayEnum
self::ALIPAY_BARCODE => '支付宝条码',
self::BALANCE_PAY => '余额支付',
self::PURCHASE_FUNDS => '采购款收银',
self::GIFT_FUNDS => '礼品券收银',
];
if ($value === true) {

View File

@ -38,8 +38,12 @@ class UserShipLists extends BaseAdminDataLists
{
$field = "id,title";
$arr[]=['id'=>0,'title'=>'一般用户'];
$arr=[];
if($this->request->__get('id')){
$this->searchWhere[]=['id','in',[1,4]];
}else{
$arr[]=['id'=>0,'title'=>'一般用户'];
}
$lists = UserShip::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->field($field)

View File

@ -19,6 +19,7 @@ class CapitalFlowLogic extends BaseLogic
$this->store = $obj;
}
}
//微信退款记录
/**
* 用户收入
@ -29,7 +30,7 @@ class CapitalFlowLogic extends BaseLogic
* @param $mark
* @return mixed
*/
public function userIncome($category, $linkType, $linkId, $amount, $mark = '')
public function userIncome($category, $linkType, $linkId, $amount, $mark = '',$type=0)
{
$model = new CapitalFlow();
$model->uid = $this->user['id'];
@ -37,8 +38,13 @@ class CapitalFlowLogic extends BaseLogic
$model->link_type = $linkType;
$model->link_id = $linkId;
$model->amount = $amount;
$model->before_balance = $this->user['now_money'];
$model->balance = bcadd($this->user['now_money'], $amount, 2);
if($type){
$model->before_balance = $this->user['now_money'];
$model->balance = $this->user['now_money'];
}else{
$model->before_balance = $this->user['now_money'];
$model->balance = bcadd($this->user['now_money'], $amount, 2);
}
$model->create_time = date('Y-m-d H:i:s');
$model->type = 'in';
$model->title = $this->getTitle($category, $amount);
@ -143,6 +149,8 @@ class CapitalFlowLogic extends BaseLogic
switch ($category) {
case 'user_balance_recharge':
return "用户充值{$amount}";
case 'user_order_purchase_pay':
return "用户采购款支付{$amount}";
case 'store_margin':
return "店铺自动扣除保证金{$amount}";
case 'store_order_income':
@ -159,6 +167,8 @@ class CapitalFlowLogic extends BaseLogic
return "退还订单推广佣金{$amount}";
case 'system_balance_add':
return "系统增加余额{$amount}";
case 'system_purchase_add':
return "系统增加采购款{$amount}";
case 'system_balance_reduce':
return "系统减少余额{$amount}";
default:

View File

@ -11,11 +11,18 @@ class CashFlowLogic extends BaseLogic
public function insert($storeId, $amount)
{
$model = new StoreCashFinanceFlow();
$model->store_id = $storeId;
$model->cash_price = $amount;
$model->receivable = $amount;
$model->status = YesNoEnum::YES;//收银台收了默认算完成了
$model->save();
$find = $model->where(['store_id' => $storeId])->whereDay('create_time')->where('status', 0)->find();
if ($find) {
$find->cash_price = bcadd($find->cash_price, $amount, 2);
$find->receivable = bcadd($find->receivable, $amount, 2);
$find->save();
} else {
$model->store_id = $storeId;
$model->cash_price = $amount;
$model->receivable = $amount;
$model->remark = '银行转账请备注:'.mt_rand(1000, 9999);
$model->status = YesNoEnum::NO; //收银台收了默认算完成了
$model->save();
}
}
}

View File

@ -6,9 +6,13 @@ use app\api\logic\order\OrderLogic;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\enum\user\UserShipEnum;
use app\common\enum\YesNoEnum;
use app\common\model\dict\DictType;
use app\common\model\finance\CapitalFlow;
use app\common\model\finance\PayNotifyLog;
use app\common\model\pay\PayNotify;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
@ -36,7 +40,7 @@ class PayNotifyLogic extends BaseLogic
{
Db::startTrans();
try {
if ($action != 'cash_pay' && $action != 'balancePay' && $action != 'purchase_funds') {
if ($action != 'cash_pay' && $action != 'balancePay' && $action != 'purchase_funds' && $action != 'gift_pay') {
$payNotifyLogLogic = new PayNotifyLogLogic();
if ($action == 'refund') {
$payNotifyLogLogic->insert($action, $extra, PayNotifyLog::TYPE_REFUND);
@ -81,19 +85,71 @@ class PayNotifyLogic extends BaseLogic
$user->save();
if ($order['spread_uid'] > 0 && $user['user_ship'] == 1) {
$oldUser = User::where('id',$order['spread_uid'])->value('purchase_funds');
$oldUser = User::where('id', $order['spread_uid'])->value('purchase_funds');
if ($oldUser < $order['pay_price']) {
$order['pay_price'] = $oldUser;
}
}
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']);
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
// self::afterPay($order);
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
}
/**
* 礼品券支付
* @param $orderSn
* @param $extra
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function gift_pay($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
$user = User::where('id', $order['uid'])->find();
if ($user['integral'] < $order['pay_price']) {
throw new \Exception('礼品券不足');
}
$order->money = $order['pay_price'];
$order->paid = 1;
$order->pay_time = time();
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
// 减去礼品券
$user->integral = bcsub($user['integral'], $order['pay_price'], 2);
$user->save();
//入礼品券表扣款记录
$sing[] = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '订单扣除兑换券',
'store_id' => $order['store_id'],
'number' => $order['pay_price'],
'financial_pm' => 0,
'user_ship' => $user['user_ship'],
];
(new UserSign())->saveAll($sing);
if ($extra && $extra['store_id']) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $extra['store_id'],
'staff_id' => $extra['staff_id']
];
OrderLogic::lessWriteOff($params);
}
self::dealProductLog($order);
}
/**
* 采购款支付
@ -122,20 +178,23 @@ class PayNotifyLogic extends BaseLogic
$user->save();
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'],'',1,$order['store_id']);
if ($user['user_ship'] == 1) {
self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS);
}
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'], '', 1, $order['store_id']);
// if ($user['user_ship'] == 1) {
// self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS);
// }
if($extra && $extra['store_id']){
if ($extra && $extra['store_id']) {
$params = [
'verify_code'=>$order['verify_code'],
'store_id'=>$extra['store_id'],
'staff_id'=>$extra['staff_id']
'verify_code' => $order['verify_code'],
'store_id' => $extra['store_id'],
'staff_id' => $extra['staff_id']
];
OrderLogic::writeOff($params);
}
self::dealProductLog($order);
// if($order['shipping_type'] == 3){
// self::descStock($order['id']);
// }
// self::afterPay($order);
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
@ -171,10 +230,13 @@ class PayNotifyLogic extends BaseLogic
} else {
$capitalFlowDao = new CapitalFlowLogic($user);
//微信支付和用户余额无关
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1,$order['store_id']);
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']);
}
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
// if ($order->pay_type == 9) {
// $extra['create_time'] = $order['create_time'];
@ -186,7 +248,7 @@ class PayNotifyLogic extends BaseLogic
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
// }
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5);
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
}
return true;
}
@ -205,10 +267,71 @@ class PayNotifyLogic extends BaseLogic
$order->refund_reason_time = time();
$order->refund_num += 1;
$order->save();
//日志记录
//加用户余额,采购款, 日志记录 加数量
$user = User::where('id', $order['uid'])->findOrEmpty();
$capitalFlowDao = new CapitalFlowLogic($user);
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额
$user->now_money = bcadd($user->now_money, $deal_money, 2);
$user->save();
//增加数量
self::addStock($order['id']);
//退款
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
}
if($order['pay_type'] == PayEnum::PURCHASE_FUNDS){//采购款
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
$user->save();
//增加数量
self::addStock($order['id']);
//退款
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
}
}
//微信日志 user_order_refund
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money,'',1);
self::addStock($order['id']);//微信
// self::afterPay($order,$extra['transaction_id']);
}
/**
* 现金退款相关
* @param $orderSn
* @param $extra
* @return true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function cash_refund($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
return true;
}
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
$order->refund_price = $order->pay_price;
$order->refund_reason_time = time();
$order->refund_num += 1;
$order->save();
//日志记录
$model = new StoreCashFinanceFlow();
$model->store_id = $order['store_id']??0;
$model->cash_price = $order->pay_price;
$model->receivable = $order->pay_price;
$model->remark = '退款';
$model->type = 1;
$model->status = YesNoEnum::YES;
$model->save();
//增加数量
self::addStock($order['id']);
return true;
}
/**
* 充值
*/
@ -248,7 +371,7 @@ class PayNotifyLogic extends BaseLogic
if (!empty($extra['payer']['openid'])) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 5);
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
}
return true;
}
@ -273,6 +396,9 @@ class PayNotifyLogic extends BaseLogic
$cashFlowLogic = new CashFlowLogic();
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
// Redis::send('push-platform-print', ['id' => $order['id']]);
}
@ -304,6 +430,9 @@ class PayNotifyLogic extends BaseLogic
self::afterPay($order);
}
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
// if ($order->pay_type == 9) {
// $extra['create_time'] = $order['create_time'];
@ -332,19 +461,18 @@ class PayNotifyLogic extends BaseLogic
$user = User::where('id', $order['uid'])->find();
//纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额)
if ($order['spread_uid'] > 0) {
$oldUser = User::where('id',$order['spread_uid'])->field('purchase_funds,user_ship')->find();
if ($oldUser && $oldUser['user_ship'] == 1){
$oldUser = User::where('id', $order['spread_uid'])->field('purchase_funds,user_ship')->find();
if ($oldUser && $oldUser['user_ship'] == 1) {
if ($oldUser['purchase_funds'] < $order['pay_price']) {
$vipFen = $oldUser['purchase_funds'];
}
}
}
elseif ($user['user_ship'] == 1){
} elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) {
$vipFrozenAmount = self::dealFrozenPrice($order['id']);
//为1的时候要去减活动价
// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2);
// d($final_price,$vipFrozenAmount);
$order['pay_price'] = bcsub($order['pay_price'],$vipFrozenAmount,2);
// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2);
// d($final_price,$vipFrozenAmount);
$order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2);
self::dealVipAmount($order, $order['pay_type']);
}
@ -383,12 +511,14 @@ class PayNotifyLogic extends BaseLogic
if ($deposit > 0) {
if ($deposit > $store_profit) {
if ($store_profit > 0) {
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update();
$financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
}
} else {
$money = bcsub($store_profit, $deposit, 2);
if ($deposit > 0) {
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update();
$financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
}
if ($money) {
@ -405,14 +535,19 @@ class PayNotifyLogic extends BaseLogic
// if ($order['is_vip'] >= 1) {
if ($order['spread_uid'] > 0) {
$financeLogic->other_arr['vip_uid'] = $order['spread_uid'];
if($vipFen){
if ($vipFen) {
$fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2);
}else{
} else {
$fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2);
}
$count_frees = bcadd($count_frees, $fees, 2);
if ($fees > 0) {
User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update();
//记录用户余额收入
$GiveUser = User::where('id', $order['spread_uid'])->find();
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
$financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //vip订单获得
$financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
}
@ -430,7 +565,7 @@ class PayNotifyLogic extends BaseLogic
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
if ($uid) {
User::where('id', $uid)->inc('integral', $fees)->update();
$village_uid=$uid;
$village_uid = $uid;
}
}
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
@ -438,63 +573,65 @@ class PayNotifyLogic extends BaseLogic
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
if ($uid) {
User::where('id', $uid)->inc('integral', $fees)->update();
$brigade_uid=$uid;
$brigade_uid = $uid;
}
}
}
}
if ($fees > 0) {
//村长获得
$sing = [];
// $sing = [];
$sing[] = [
'uid' => $village_uid,
'order_id' => $order['order_id'],
'title' => '村长订单获得兑换券',
'store_id' => $order['store_id'],
'number' => $fees,
'financial_pm' => 1,
'user_ship' => 2,
];
$sing[] = [
'uid' => $brigade_uid,
'order_id' => $order['order_id'],
'title' => '队长订单获得兑换券',
'store_id' => $order['store_id'],
'number' => $fees,
'financial_pm' => 1,
'user_ship' => 3,
];
$sing[] = [
'uid' => $village_uid,
'order_id' => $order['order_id'],
'title' => '订单扣除兑换券',
'store_id' => $order['store_id'],
'number' => $fees,
'financial_pm' => 0,
'user_ship' => 2,
];
$sing[] = [
'uid' => $brigade_uid,
'order_id' => $order['order_id'],
'title' => '订单扣除兑换券',
'store_id' => $order['store_id'],
'number' => $fees,
'financial_pm' => 0,
'user_ship' => 3,
];
// if ($village_uid > 0) {
// $financeLogic->other_arr['vip_uid'] = $village_uid;
// }
// $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
// $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
// $sing[] = [
// 'uid' => $village_uid,
// 'order_id' => $order['order_id'],
// 'title' => '村长订单获得兑换券',
// 'store_id' => $order['store_id'],
// 'number' => $fees,
// 'financial_pm' => 1,
// 'user_ship' => 2,
// ];
// $sing[] = [
// 'uid' => $brigade_uid,
// 'order_id' => $order['order_id'],
// 'title' => '队长订单获得兑换券',
// 'store_id' => $order['store_id'],
// 'number' => $fees,
// 'financial_pm' => 1,
// 'user_ship' => 3,
// ];
// $sing[] = [
// 'uid' => $village_uid,
// 'order_id' => $order['order_id'],
// 'title' => '订单扣除兑换券',
// 'store_id' => $order['store_id'],
// 'number' => $fees,
// 'financial_pm' => 0,
// 'user_ship' => 2,
// ];
// $sing[] = [
// 'uid' => $brigade_uid,
// 'order_id' => $order['order_id'],
// 'title' => '订单扣除兑换券',
// 'store_id' => $order['store_id'],
// 'number' => $fees,
// 'financial_pm' => 0,
// 'user_ship' => 3,
// ];
if ($village_uid > 0) {
SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update();
$financeLogic->other_arr['vip_uid'] = $village_uid;
}
$financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
//队长获得
// if ($brigade_uid > 0) {
// $financeLogic->other_arr['vip_uid'] = $brigade_uid;
// }
// $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
// $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$user_sing->saveAll($sing);
if ($brigade_uid > 0) {
SystemStore::where('id', $brigade_uid)->inc('store_money', $fees)->update();
$financeLogic->other_arr['vip_uid'] = $brigade_uid;
}
$financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
// $user_sing->saveAll($sing);
//其他获得
$financeLogic->other_arr['vip_uid'] = 0;
$financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
@ -543,10 +680,10 @@ class PayNotifyLogic extends BaseLogic
public static function dealFrozenPrice($oid)
{
$detail = StoreOrderCartInfo::where('oid',$oid)->select()->toArray();
$detail = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
$total_vip = 0;
foreach ($detail as $value){
$total_vip +=$value['cart_info']['vip_frozen_price'];
foreach ($detail as $value) {
$total_vip += $value['cart_info']['vip_frozen_price'];
}
return $total_vip;
}
@ -562,20 +699,20 @@ class PayNotifyLogic extends BaseLogic
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function dealVipAmount($order,$pay_type =1,$transaction_id = 0)
public static function dealVipAmount($order, $pay_type = 1, $transaction_id = 0)
{
$total_vip = self::dealFrozenPrice($order['id']);
$data=[
$data = [
'order_id' => $order['id'],
'transaction_id' => $transaction_id??0,
'order_sn' =>$order['order_id'],
'transaction_id' => $transaction_id ?? 0,
'order_sn' => $order['order_id'],
'user_id' => $order['uid'],
'number' => $total_vip,
'pay_type' => $pay_type??1,
'pay_type' => $pay_type ?? 1,
'status' => 0,
'store_id' => $order['store_id'],
'staff_id' => $order['staff_id'],
'create_time'=>time()
'create_time' => time()
];
Db::name('vip_flow')->insert($data);
return true;
@ -594,31 +731,114 @@ class PayNotifyLogic extends BaseLogic
$store_id = $order['store_id'];
$cart_id = $order['cart_id'];
$uid = $order['uid'];
if($uid && $cart_id && $store_id){
$cart_id = explode(',',$cart_id);
if ($uid && $cart_id && $store_id) {
$cart_id = explode(',', $cart_id);
$productLog = StoreProductLog::where([
'uid'=>$uid
])->whereIn('cart_id',$cart_id)
'uid' => $uid
])->whereIn('cart_id', $cart_id)
->select()->toArray();
foreach ($productLog as &$value){
foreach ($productLog as &$value) {
$value['pay_uid'] = $uid;
$value['oid'] = $order['id'];
$cart_info = StoreOrderCartInfo::where([
'uid'=>$uid,'old_cart_id'=>$value['cart_id'],'store_id'=>$store_id
'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'store_id' => $store_id
])->find();
$value['order_num'] = $cart_info['cart_num']??1;
$value['pay_num'] = $cart_info['cart_num']??1;
$value['pay_price'] = $cart_info['price']??0;
$value['cost_price'] = $cart_info['cart_info']['cost']??0;
$value['order_num'] = $cart_info['cart_num'] ?? 1;
$value['pay_num'] = $cart_info['cart_num'] ?? 1;
$value['pay_price'] = $cart_info['price'] ?? 0;
$value['cost_price'] = $cart_info['cart_info']['cost'] ?? 0;
$value['update_time'] = time();
unset($value['create_time'],$value['delete_time']);
unset($value['create_time'], $value['delete_time']);
}
(new StoreProductLog())->saveAll($productLog);
}
return true;
}
public static function descSwap($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'swap' => $StoreBranchProduct['swap'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
}
(new StoreBranchProduct())->saveAll($updateData);
}
/**
* 扣库存
* @param $oid
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function descStock($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
if ($StoreBranchProduct) {
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
}
}
(new StoreBranchProduct())->saveAll($updateData);
}
/**
* 加库存
* @param $oid
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function addStock($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
if ($StoreBranchProduct) {
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
// 'sales' => ['inc', $v['cart_num']]
];
}
}
(new StoreBranchProduct())->saveAll($updateData);
}
}

View File

@ -50,8 +50,9 @@ class StoreOrderLogic extends BaseLogic
self::$activity_price = 0; //活动减少
self::$store_price = 0; //门店零售价
/** 计算价格 */
$pay_type = isset($params['pay_type'])?$params['pay_type']:0;
foreach ($cart_select as $k => $v) {
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find();
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,swap')->withTrashed()->find();
if (!$find) {
continue;
}
@ -75,6 +76,11 @@ class StoreOrderLogic extends BaseLogic
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
$cart_select[$k]['deduction_price'] =$deduction_price_count;
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
}
if($pay_type ==19){
if ($find['swap'] < $cart_select[$k]['cart_num']) {
throw new \Exception('兑换数量不足');
}
}
//利润
// $cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润
@ -111,18 +117,22 @@ class StoreOrderLogic extends BaseLogic
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格
// self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
}
if ($user && $user['user_ship'] == 1) {
if ($user && $user['user_ship'] == 1 && $pay_type !=17) {
$pay_price = self::$pay_price;
$activity_string = '';
}else{
$pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
$activity_string = '减免';
}
if($pay_price < 500){
throw new \think\Exception('金额低于500');
if($pay_type == 19){
$pay_price = self::$pay_price;
$activity_string = '';
}
// if($pay_price < 500){
// throw new \think\Exception('金额低于500');
// }
$vipPrice = 0;
//成本价 收益
$order = [
@ -227,6 +237,9 @@ class StoreOrderLogic extends BaseLogic
$order['refund_status_name'] = OrderEnum::refundStatus($order['refund_status']) ?? '';
$order['refund_type_name'] = OrderEnum::refundType($order['refund_type']) ?? '';
$order['pay_type_name'] =PayEnum::getPaySceneDesc($order['pay_type']) ?? '';
if ($order['pay_type'] == 19){
$order['deduction_price'] = "0.00";
}
$detail =StoreOrderCartInfo::where('oid',$order['id'])->find()->toArray();
$vip =0;
@ -306,9 +319,9 @@ class StoreOrderLogic extends BaseLogic
* @param $extra
* @return float|\think\db\Query
*/
public function storeOrderSumByDate($storeId, $start, $end, $extra = [], $field = 'pay_price')
public function storeOrderSumByDate($start, $end, $extra = [], $field = 'pay_price')
{
return StoreOrder::where('store_id', $storeId)->where('paid', 1)->where($extra)->whereBetweenTime('pay_time', $start, $end)->sum($field);
return StoreOrder::where($extra)->whereBetweenTime('pay_time', $start, $end)->sum($field);
}
/**
@ -355,14 +368,14 @@ class StoreOrderLogic extends BaseLogic
throw new \Exception('用户未设置手机号');
}
$template = getenv('SMS_TEMPLATE');
if($type){
$check =(new SmsService())->client($phone,$template,$code,1);
}else{
$check =(new SmsService())->client($phone,$template,$code);
}
$check =(new SmsService())->client($phone,$template,$code);
if($check){
$remark = $param['uid'].'_smsPay';
if($type == 1){
$remark = $param['uid'].'_smsPay';
}else{
$remark = $param['uid'].'_giftPay';
}
Cache::set($remark,$code,5*60);
return true;
}else{

View File

@ -32,4 +32,35 @@ class BaseModel extends Model
{
return trim($value) ? FileService::setFileUrl($value) : '';
}
/**
* 曲线统计
* @param $time
* @param $type
* @param $timeType
* @return mixed
*/
public function getCurveData($where, $time, $str, string $group = 'create_time')
{
return $this->where($where)
->when(isset($time['timeKey']), function ($query) use ($time, $str, $group) {
$query->whereBetweenTime($group, $time['timeKey']['start_time'], $time['timeKey']['end_time']);
if ($time['timeKey']['days'] == 1) {
$timeUinx = "%H";
} elseif ($time['timeKey']['days'] == 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($time['timeKey']['days'] == 365) {
$timeUinx = "%Y-%m";
} elseif ($time['timeKey']['days'] > 1 && $time['timeKey']['days'] < 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($time['timeKey']['days'] > 30 && $time['timeKey']['days'] < 365) {
$timeUinx = "%Y-%m";
} else {
$timeUinx = "%Y-%m";
}
$query->field("$str as number,FROM_UNIXTIME($group, '$timeUinx') as time");
$query->group("FROM_UNIXTIME($group, '$timeUinx')");
})
->order("$group ASC")->select()->toArray();
}
}

View File

@ -4,6 +4,7 @@ namespace app\common\model\store_branch_product_attr_value;
use app\common\model\BaseModel;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_product_attr_value\StoreProductAttrValue;
use think\model\concern\SoftDelete;
@ -21,7 +22,7 @@ class StoreBranchProductAttrValue extends BaseModel
public function attr()
{
return $this->hasOne(StoreProductAttrValue::class, 'unique', 'unique')->bind(['image']);
return $this->hasOne(StoreBranchProduct::class, 'product_id', 'product_id')->bind(['image']);
}
}

View File

@ -22,7 +22,10 @@ class StoreOrder extends BaseModel
use SoftDelete;
protected $name = 'store_order';
protected $deleteTime = 'delete_time';
// public function getPayTimeAttr($value)
// {
// return $value?date('Y-m-d H:i:s', $value):'';
// }
public function store()
{
return $this->hasOne(SystemStore::class, 'id', 'store_id')
@ -77,7 +80,7 @@ class StoreOrder extends BaseModel
$query->where('channel_type', $type);
})->where('paid', 1)->where('paid', '>=', 0)->where(function ($query) use ($time) {
if ($time[0] == $time[1]) {
$query->whereDay('create_time', $time[0]);
$query->whereDay('create_time', date('Y-m-d',$time[0]));
} else {
$time[1] = $time[1] + 86400;
$query->whereTime('create_time', 'between', $time);
@ -85,34 +88,4 @@ class StoreOrder extends BaseModel
})->field("FROM_UNIXTIME(create_time,'$timeType') as days,$str as num")
->group('days')->select()->toArray();
}
/**
* 曲线统计
* @param $time
* @param $type
* @param $timeType
* @return mixed
*/
public function getCurveData($where,$time,$str)
{
return $this->where($where)
->when(isset($time['timeKey']), function ($query) use ($time,$str) {
$query->whereBetweenTime('create_time', $time['timeKey']['start_time'], $time['timeKey']['end_time']);
if ($time['timeKey']['days'] == 1) {
$timeUinx = "%H";
} elseif ($time['timeKey']['days'] == 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($time['timeKey']['days'] == 365) {
$timeUinx = "%Y-%m";
} elseif ($time['timeKey']['days'] > 1 && $time['timeKey']['days'] < 30) {
$timeUinx = "%Y-%m-%d";
} elseif ($time['timeKey']['days'] > 30 && $time['timeKey']['days'] < 365) {
$timeUinx = "%Y-%m";
} else {
$timeUinx = "%Y-%m";
}
$query->field("$str as number,FROM_UNIXTIME(create_time, '$timeUinx') as time");
$query->group("FROM_UNIXTIME(create_time, '$timeUinx')");
})
->order('create_time ASC')->select()->toArray();
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace app\common\model\store_order_transshipment;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 调货订单模型
* Class StoreOrderTransshipment
* @package app\common\model\store_order_transshipment
*/
class StoreOrderTransshipment extends BaseModel
{
use SoftDelete;
protected $name = 'store_order_transshipment';
protected $deleteTime = 'delete_time';
}

View File

@ -0,0 +1,22 @@
<?php
namespace app\common\model\store_order_transshipment_info;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 调货订单商品模型
* Class StoreOrderTransshipmentInfo
* @package app\common\model\store_order_transshipment_info
*/
class StoreOrderTransshipmentInfo extends BaseModel
{
use SoftDelete;
protected $name = 'store_order_transshipment_info';
protected $deleteTime = 'delete_time';
}

View File

@ -189,7 +189,7 @@ class User extends BaseModel
$query->where('user_type', $type);
})->where(function ($query) use ($time) {
if ($time[0] == $time[1]) {
$query->whereDay('create_time', $time[0]);
$query->whereDay('create_time', date('Y-m-d',$time[0]));
} else {
$time[1] = $time[1] + 86400;
$query->whereTime('create_time', 'between', $time);

View File

@ -33,7 +33,7 @@ class UserVisit extends BaseModel
$query->where('channel_type', $type);
})->where(function ($query) use ($time) {
if ($time[0] == $time[1]) {
$query->whereDay('create_time', $time[0]);
$query->whereDay('create_time', date('Y-m-d',$time[0]));
} else {
$time[1] = $time[1] + 86400;
$query->whereTime('create_time', 'between', $time);

View File

@ -0,0 +1,22 @@
<?php
namespace app\common\model\user_create_log;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 用户前端添加记录
* Class UserCreateLog
* @package app\common\model\user_create_log
*/
class UserCreateLog extends BaseModel
{
use SoftDelete;
protected $name = 'user_create_log';
protected $deleteTime = 'delete_time';
}

View File

@ -32,7 +32,7 @@ class UserRecharge extends BaseModel
$query->where('channel_type', $type);
})->where($where)->where(function ($query) use ($time) {
if ($time[0] == $time[1]) {
$query->whereDay('create_time', $time[0]);
$query->whereDay('create_time', date('Y-m-d',$time[0]));
} else {
$time[1] = $time[1] + 86400;
$query->whereTime('create_time', 'between', $time);

View File

@ -18,5 +18,4 @@ class UserSign extends BaseModel
protected $name = 'user_sign';
protected $deleteTime = 'delete_time';
}

View File

@ -108,7 +108,7 @@ class WeChatMnpService
}
$dateTime = new DateTime(date('Y-m-d H:i:s'));
$formattedDateTime = $dateTime->format('Y-m-d\TH:i:s.uP');
if(is_array($logistics_type,[1,2,4])){
if(in_array($logistics_type,[1,2,4])){
$item_desc='商品';
}else{
$item_desc='充值';

View File

@ -476,3 +476,14 @@ if (!function_exists('countRate')) {
return bcmul(bcdiv((bcsub($nowValue, $lastValue, 2)), $lastValue, 4), 100, 2);
}
}
if (!function_exists('payPassword')) {
//支付密码
function payPassword($password){
return password_hash($password,PASSWORD_BCRYPT);
}
}

View File

@ -26,6 +26,7 @@ class PushDeliverySend implements Consumer
{
$package['max_attempts']=0;
Log::error('推送小程序发货通知失败:'.$package['data']['order_id']);
Log::error('推送小程序发货通知失败:' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile());
return $package;
}
}

View File

@ -59,6 +59,7 @@ class StoreStorageSend implements Consumer
'cost' => $find['cost'],
'purchase' => $find['purchase'],
'vip_price' => $find['vip_price'],
'manufacturer_information' => $find['manufacturer_information']??'',
'unit' => $find['unit'],
'batch' => $find['batch'],
'store_id' => $store_id,

View File

@ -11,13 +11,20 @@ use DateTime;
class IndexController extends BaseLikeController
{
public $store_id=3;
public function index()
{
$res = OrderLogic::dayPayPrice(5);
$store_id = $this->store_id;
if($store_id){
$where['store_id'] = $store_id;
}
$where['paid'] = 1;
$res = OrderLogic::dayPayPrice($where);
if (OrderLogic::hasError()) {
return $this->fail(OrderLogic::getError()); //获取错误信息并返回错误信息
}
return $this->success('ok', ['dayPayPrice' => $res,'title'=>'喻寺镇农(特)产品交易大数据']);
return $this->success('ok', ['dayPayPrice' => $res,'title'=>'百合镇农(特)产品交易大数据']);
}
public function user()
{
@ -32,7 +39,12 @@ class IndexController extends BaseLikeController
$date = date('Y-m-d', $timestamp);
$dates[]=$date;
}
$res = UserLogic::userCount(5,$dates);
$store_id = $this->store_id;
$where=[];
if($store_id){
$where['store_id'] = $store_id;
}
$res = UserLogic::userCount($where,$dates);
if (UserLogic::hasError()) {
return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息
}
@ -44,7 +56,12 @@ class IndexController extends BaseLikeController
*/
public function product_count()
{
$res = ProductLogic::Count(5);
$store_id = $this->store_id;
$where=[];
if($store_id){
$where['store_id'] = $store_id;
}
$res = ProductLogic::Count($where);
if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
}
@ -55,7 +72,12 @@ class IndexController extends BaseLikeController
*/
public function order_user_num_count()
{
$res = OrderLogic::Count(5);
$store_id = $this->store_id;
$where=[];
if($store_id){
$where['store_id'] = $store_id;
}
$res = OrderLogic::Count($where);
if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
}
@ -66,7 +88,12 @@ class IndexController extends BaseLikeController
*/
public function sales_ranking()
{
$res = ProductLogic::sales(5);
$store_id = $this->store_id;
$where=[];
if($store_id){
$where['store_id'] = $store_id;
}
$res = ProductLogic::sales($where);
if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
}
@ -87,7 +114,12 @@ class IndexController extends BaseLikeController
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
}
$res = UserLogic::TradeCount(5, $dates);
$store_id = $this->store_id;
$where=[];
if($store_id){
$where['store_id'] = $store_id;
}
$res = UserLogic::TradeCount($where, $dates);
if (UserLogic::hasError()) {
return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息
}
@ -98,7 +130,12 @@ class IndexController extends BaseLikeController
*/
public function street_currday_order_count()
{
$res = OrderLogic::Currday(5);
$store_id = $this->store_id;
$where=[];
if($store_id){
$where['store_id'] = $store_id;
}
$res = OrderLogic::Currday($where);
if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
}

View File

@ -8,12 +8,12 @@ use app\common\model\user_recharge\UserRecharge;
class OrderLogic extends BaseLogic
{
public static function Count($store_id)
public static function Count($where)
{
$orderNum = StoreOrder::where('store_id', $store_id)->whereDay('create_time')->count();
$orderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereDay('create_time')->group('uid')->count();
$monthOrderNum = StoreOrder::where('store_id', $store_id)->whereMonth('create_time')->count();
$monthOrderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereMonth('create_time')->group('uid')->count();
$orderNum = StoreOrder::where($where)->whereDay('create_time')->count();
$orderPayNum = StoreOrder::where($where)->where('paid', 1)->whereDay('create_time')->group('uid')->count();
$monthOrderNum = StoreOrder::where($where)->whereMonth('create_time')->count();
$monthOrderPayNum = StoreOrder::where($where)->where('paid', 1)->whereMonth('create_time')->group('uid')->count();
$data = [
"orderNum" => $orderNum,
"monthOrderNum" => $monthOrderNum,
@ -26,7 +26,7 @@ class OrderLogic extends BaseLogic
];
return $data;
}
public static function Currday($store_id)
public static function Currday($where)
{
$date = date("Y-m-d");
$startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳
@ -42,11 +42,11 @@ class OrderLogic extends BaseLogic
$endTimeSegment = date('Y-m-d H:i:s', $endTimeSegment);
$yesterstartTimeSegment = date('Y-m-d H:i:s', $time - 86400);
// 统计当前时间段的订单
$todayAmount = StoreOrder::where('store_id', $store_id)
$todayAmount = StoreOrder::where($where)
->where('paid', 1)
->whereBetween('create_time', [strtotime($startTimeSegment), strtotime($endTimeSegment)])
->sum('pay_price');
$yesterdayAmount = StoreOrder::where('store_id', $store_id)
$yesterdayAmount = StoreOrder::where($where)
->where('paid', 1)
->whereBetween('create_time', [strtotime($yesterstartTimeSegment), strtotime($yesterendTimeSegment)])
->sum('pay_price');
@ -57,13 +57,14 @@ class OrderLogic extends BaseLogic
}
return $data;
}
public static function dayPayPrice($store_id)
public static function dayPayPrice($where)
{
$todayAmount = UserRecharge::where('store_id', $store_id)
->where('paid', 1)
$todayAmount = UserRecharge::where($where)
->whereDay('create_time')
->sum('price');
return $todayAmount;
$pay_price = StoreOrder::where($where)
->whereDay('create_time')
->sum('pay_price');
return bcadd($todayAmount, $pay_price, 2);
}
}

View File

@ -7,18 +7,18 @@ use app\common\model\store_branch_product\StoreBranchProduct;
class ProductLogic extends BaseLogic
{
public static function Count($store_id)
public static function Count($where)
{
$todayProductCount=StoreBranchProduct::where('store_id',$store_id)->count();
$yestertodayProductCount=StoreBranchProduct::where('store_id',$store_id)->where('create_time', '<',strtotime(date('Y-md'))-1)->count();
$todayProductCount=StoreBranchProduct::where($where)->count();
$yestertodayProductCount=StoreBranchProduct::where($where)->where('create_time', '<',strtotime(date('Y-md'))-1)->count();
if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
$weeklyProductTotalGrowthRate = 0;
} else {
$weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100;
}
$todayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time')->count();
$yestertodayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time', 'yesterday')->count();
$todayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time')->count();
$yestertodayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time', 'yesterday')->count();
if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
$weeklyNewProductTotalGrowthRate = 0;
} else {
@ -44,8 +44,8 @@ class ProductLogic extends BaseLogic
return $data;
}
public static function sales($store_id){
$select=StoreBranchProduct::where('store_id',$store_id)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select();
public static function sales($where){
$select=StoreBranchProduct::where($where)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select();
return $select?->toArray();
}
}

View File

@ -9,24 +9,24 @@ use app\common\model\user_recharge\UserRecharge;
class UserLogic extends BaseLogic
{
public static function userCount($store_id,$dates)
public static function userCount($where,$dates)
{
$data = [];
foreach ($dates as $k=>$date) {
$data[$k]['newUserCount']=UserRecharge::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
$data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->group('uid')->count();
$data[$k]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
$data[$k]['newUserCount']=UserRecharge::whereDay('create_time', $date)->where($where)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
$data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where($where)->group('uid')->count();
$data[$k]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where($where)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
}
return $data;
}
public static function TradeCount($store_id,$dates)
public static function TradeCount($where,$dates)
{
$data = [];
foreach ($dates as $k=>$date) {
$data[$k]['date']=$date;
$data[$k]['visitUser']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_visit_count_' . $date, 300)->group('uid')->count();
$data[$k]['orderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_order_count_' . $date, 300)->group('uid')->count();
$data[$k]['payOrderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->cache('statistics_store_order_pay_count_' . $date, 300)->group('uid')->count();
$data[$k]['visitUser']=StoreVisit::whereDay('create_time', $date)->where($where)->cache('statistics_store_visit_count_' . $date, 300)->group('uid')->count();
$data[$k]['orderUser']=StoreOrder::whereDay('create_time', $date)->where($where)->cache('statistics_store_order_count_' . $date, 300)->group('uid')->count();
$data[$k]['payOrderUser']=StoreOrder::whereDay('create_time', $date)->where($where)->where('paid',1)->cache('statistics_store_order_pay_count_' . $date, 300)->group('uid')->count();
}
return $data;
}

View File

@ -151,22 +151,8 @@ class WorkbenchController extends BaseAdminController
// ]
public function get_product_ranking()
{
// $params = $this->request->get();
$dateRange = $this->request->get('date');
// 拆分日期范围
list($startDate, $endDate) = explode('-', $dateRange);
$startTime = str_replace('/', '-', $startDate);
$endTime = str_replace('/', '-', $endDate);
if (empty($startTime)) {
$startTime = strtotime(date('Y-m-d'));
$endTime = $startTime + 86400;
}
$where = [
['create_time', 'between', [$startTime, $endTime]],
['store_id','=',$this->request->adminInfo['store_id']]
];
$workbench = WorkbenchLogic::get_product_ranking($where);
$workbench = WorkbenchLogic::get_product_ranking(['create_time'=>$dateRange],$this->request->adminInfo['store_id']);
return $this->data($workbench);
}

View File

@ -0,0 +1,66 @@
<?php
namespace app\store\controller\store_cash_finance_flow;
use app\store\controller\BaseAdminController;
use app\admin\logic\store_cash_finance_flow\StoreCashFinanceFlowLogic;
use app\admin\validate\store_cash_finance_flow\StoreCashFinanceFlowValidate;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\store\lists\store_cash_finance_flow\StoreCashFinanceFlowLists;
/**
* 现金流水控制器
* Class StoreCashFinanceFlowController
* @package app\admin\controller\store_cash_finance_flow
*/
class StoreCashFinanceFlowController extends BaseAdminController
{
/**
* @notes 获取现金流水列表
* @return \think\response\Json
* @author admin
* @date 2024/06/06 10:29
*/
public function lists()
{
return $this->dataLists(new StoreCashFinanceFlowLists());
}
/**
* @notes 编辑现金流水
* @return \think\response\Json
* @author admin
* @date 2024/06/06 10:29
*/
public function edit()
{
$id=$this->request->post('id');
$res=StoreCashFinanceFlow::where(['store_id'=>$this->adminInfo['store_id'],'id'=>$id])->update(['store_status'=>1]);
if ($res) {
return $this->success('上交成功,等待财务审核', [], 1, 1);
}
return $this->fail('没有更新');
}
/**
* @notes 获取现金流水详情
* @return \think\response\Json
* @author admin
* @date 2024/06/06 10:29
*/
public function detail()
{
$params = (new StoreCashFinanceFlowValidate())->goCheck('detail');
$result = StoreCashFinanceFlowLogic::detail($params);
$result['image']='https://lihaiim.oss-cn-chengdu.aliyuncs.com/public/uploads/images/20240619/20240619104553f7e108704.jpg';
$result['bank_code']='456565656';
$result['bank_name']='里海农科';
$result['bank_address']='泸州支行';
return $this->data($result);
}
}

View File

@ -23,7 +23,9 @@ use app\common\model\system_store\SystemStore;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user_recharge\UserRecharge;
use app\store\validate\store_order\StoreOrderValidate;
use support\Cache;
use support\Log;
use think\Exception;
use Webman\RedisQueue\Redis;
/**
@ -82,7 +84,7 @@ class StoreOrderController extends BaseAdminController
$cartId = (array)$this->request->post('cart_id', []);
$params = $this->request->post();
$params['store_id'] = $this->adminInfo['store_id'];
$user=User::where('id',$params['uid'])->find();
$user = User::where('id', $params['uid'])->find();
$res = StoreOrderLogic::cartIdByOrderInfo($cartId, null, $user, $params);
if ($res == false) {
$msg = StoreOrderLogic::getError();
@ -107,10 +109,17 @@ class StoreOrderController extends BaseAdminController
if (!$order) {
return $this->fail(StoreOrderLogic::getError());
}
if ($order['order']['pay_price'] > $user['purchase_funds']) {
return $this->fail('当前用户采购款不足支付');
if ($params['type'] == 1) {
if ($order['order']['pay_price'] > $user['purchase_funds']) {
return $this->fail('当前用户采购款不足支付');
}
} elseif ($params['type'] == 2) {
if ($order['order']['pay_price'] > $user['integral']) {
return $this->fail('当前用户礼品券不足支付');
}
}
$res = (new StoreOrderLogic())->dealSendSms($params);
$res = (new StoreOrderLogic())->dealSendSms($params, $params['type']);
if ($res) {
return $this->success('发送成功', [], 1, 0);
} else {
@ -128,14 +137,33 @@ class StoreOrderController extends BaseAdminController
$pay_type = (int)$this->request->post('pay_type');
$addressId = (int)$this->request->post('address_id');
$auth_code = $this->request->post('auth_code'); //微信支付条码
$uid=$this->request->post('uid');
$uid = $this->request->post('uid');
$params = $this->request->post();
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS) {
if (
$auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS
&& $pay_type != PayEnum::GIFT_FUNDS
) {
return $this->fail('支付条码不能为空');
}
if (count($cartId) > 100) {
return $this->fail('购物车商品不能超过100个');
}
if ($pay_type == PayEnum::PURCHASE_FUNDS) {
$remark = $uid . '_smsPay';
$code = Cache::get($remark);
if ($code && isset($params['code']) && $code != $params['code']) {
throw new Exception('验证码错误');
}
}
if ($pay_type == PayEnum::GIFT_FUNDS) {
$remark = $uid . '_giftPay';
$code = Cache::get($remark);
if ($code && isset($params['code']) && $code != $params['code']) {
throw new Exception('验证码错误');
}
}
$user = null;
if ($uid) {
$user = User::where('id', $uid)->find();
@ -147,11 +175,17 @@ class StoreOrderController extends BaseAdminController
case PayEnum::PURCHASE_FUNDS:
//采购款支付
PayNotifyLogic::handle('purchase_funds', $order['order_id'], [
'uid' => $uid,'store_id'=>$this->request->adminInfo['store_id'],
'staff_id'=>$this->request->adminInfo['admin_id']
'uid' => $uid, 'store_id' => $this->request->adminInfo['store_id'],
'staff_id' => $this->request->adminInfo['admin_id']
]);
return $this->success('采购款支付成功', ['id' => $order['id']]);
case PayEnum::GIFT_FUNDS:
//礼品券支付
PayNotifyLogic::handle('gift_pay', $order['order_id'], [
'store_id' => $this->request->adminInfo['store_id'],
'staff_id' => $this->request->adminInfo['admin_id']
]);
return $this->success('礼品券支付成功', ['id' => $order['id']]);
case PayEnum::CASH_PAY:
//现金支付
PayNotifyLogic::handle('cash_pay', $order['order_id']);
@ -311,6 +345,12 @@ class StoreOrderController extends BaseAdminController
*/
public function rechange_amount()
{
// $order = UserRecharge::where('order_id','CZ1719052252643357')->find();
// $order['pay_price'] = $order['price'];
// d(1);
// PayNotifyLogic::handle('recharge', $order['order_id'], $order);
// d(1);
$pay_type = $this->request->post('pay_type');
$auth_code = $this->request->post('auth_code'); //微信支付条码
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) {
@ -327,7 +367,13 @@ class StoreOrderController extends BaseAdminController
];
$order = UserRecharge::create($data);
$order['pay_price'] = $order['price'];
$order['buyer_pay_amount'] = $order['price'];
switch ($pay_type) {
case PayEnum::CASH_PAY:
//现金支付
PayNotifyLogic::handle('recharge', $order['order_id'], $order,'CASH_PAY');
return $this->success('现金支付成功', ['id' => $order['id']]);
break;
case PayEnum::WECHAT_PAY_BARCODE:
//微信条码支付
$result = PaymentLogic::codepay($auth_code, $order);

View File

@ -0,0 +1,72 @@
<?php
namespace app\store\lists\store_cash_finance_flow;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\system_store\SystemStore;
/**
* 现金流水列表
* Class StoreCashFinanceFlowLists
* @package app\admin\listsstore_cash_finance_flow
*/
class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/06/06 10:29
*/
public function setSearch(): array
{
return [
"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/06/06 10:29
*/
public function lists(): array
{
$this->searchWhere[]=['store_id','=',$this->adminInfo['store_id']];
return StoreCashFinanceFlow::where($this->searchWhere)
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'status'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
$item->store_name =SystemStore::where('id', $item->store_id)->value('name');
if($item->admin_id>0){
$item->admin_name =Admin::where('id', $item->admin_id)->value('name');
}
})
->toArray();
}
/**
* @notes 获取现金流水数量
* @return int
* @author admin
* @date 2024/06/06 10:29
*/
public function count(): int
{
return StoreCashFinanceFlow::where($this->searchWhere)->count();
}
}

View File

@ -28,7 +28,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array
{
return [
'=' => ['pay_type','paid'],
'=' => ['pay_type', 'paid'],
'%like%' => ['order_id'],
'between_time' => 'create_time',
];
@ -46,37 +46,40 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
$store_id = $this->adminInfo['store_id']??5;
$this->searchWhere[] = ['store_id' ,'=',$store_id];
$is_sashier=$this->request->get('is_sashier');
if($is_sashier==1){//收银台订单
$this->searchWhere[] = ['pay_type','in',[17,9,13,18]];
}elseif($is_sashier==2){//小程序订单
$this->searchWhere[] = ['pay_type','in',[7,3,18]];
$store_id = $this->adminInfo['store_id'] ?? 5;
$is_sashier = $this->request->get('is_sashier');
if ($is_sashier == 1) { //收银台订单
$this->searchWhere[] = ['store_id', '=', $store_id];
$this->searchWhere[] = ['pay_type', 'in', [17, 9, 13, 18,19]];
} elseif ($is_sashier == 2) { //小程序订单
$this->searchWhere[] = ['pay_type', 'in', [7, 3, 18,19]];
}
return StoreOrder::where($this->searchWhere)
->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status','paid'])
->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'paid', 'total_num'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) use ($store_id) {
$item['pay_time'] = $item['pay_time'] > 0 ? date('Y-m-d H:i:s', $item['pay_time']) : '';
$item['pay_type_name'] =PayEnum::getPaySceneDesc($item['pay_type']) ?? '';
if (empty($item['pay_time'])) {
$item['pay_time'] = '';
}else{
$item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
}
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']) ?? '';
$item['status_name'] = OrderEnum::getOrderType($item['status']) ?? '';
if ($item['paid'] == 0) {
$item['paid_name'] = '待支付';
}else{
} else {
$item['paid_name'] = '已支付';
}
$product_id = StoreOrderCartInfo::where('oid', $item['id'])->limit(3)->column('product_id');
if ($product_id) {
$item['product_info'] = StoreBranchProduct::whereIn('product_id' ,$product_id)->where('store_id', $store_id)->field(['product_id', 'store_name', 'image', 'price'])
->select();
} else {
$item['product_info'] = [];
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
->limit(3)->select();
foreach ($product as &$items) {
$items['store_name'] = $items['cart_info']['name'];
$items['image'] = $items['cart_info']['image'];
$items['price'] = $items['cart_info']['price'];
unset($items['cart_info']);
}
$item['product_info'] = $product;
return $item;
})
->toArray();

View File

@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
{
return StoreBranchProduct::where($this->searchWhere)
->where('store_id', $this->adminInfo['store_id'])
->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase'])
->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase', 'vip_price'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {

View File

@ -43,7 +43,8 @@ class StoreProductAttrValueLists extends BaseAdminDataLists implements ListsSear
public function lists(): array
{
return StoreBranchProductAttrValue::with('attr')->where($this->searchWhere)
->field(['id', 'product_id', 'stock', 'unique', 'sales', 'bar_code'])
->field(['id', 'product_id', 'stock', 'unique', 'sales', 'bar_code'
])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()

View File

@ -47,7 +47,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
{
$this->searchWhere[] = ['store_id','=',$this->adminInfo['store_id']];//只显示当前门店的入库记录
if($this->request->__get('status')==-1){
$this->searchWhere[] = ['status','>',0];
$this->searchWhere[] = ['status','>=',0];
}
return SystemStoreStorage::where($this->searchWhere)
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status'])

View File

@ -28,6 +28,8 @@ use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_log\StoreProductLog;
use app\common\model\store_visit\StoreVisit;
use app\common\model\system_store\SystemStore;
use app\common\model\user_recharge\UserRecharge;
@ -50,32 +52,44 @@ class WorkbenchLogic extends BaseLogic
$endTime = $params['end_time'];
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
$where = ['paid' => 1,'refund_status'=>0];
$userRechargeWhere = ['paid' => 1];
$cashFinanceWhere = [];
$storeFinanceWhere = ['financial_type'=>2,'financial_pm'=>1];
$storeFinanceWhereTwo = ['financial_type'=>11,'financial_pm'=>0];
if ($params['store_id'] != 0) {
$where['store_id'] = $params['store_id'];
$userRechargeWhere['store_id'] = $params['store_id'];
$cashFinanceWhere = ['store_id' => $params['store_id']];
$storeFinanceWhere['store_id'] = $params['store_id'];
$storeFinanceWhereTwo['store_id'] = $params['store_id'];
}
$orderLogic = new StoreOrderLogic();
//订单总金额
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime);
$data['order_amount'] = $orderLogic->storeOrderSumByDate($startTime, $endTime, $where);
//余额支付总金额
$data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['pay_type' => PayEnum::BALANCE_PAY]);
$data['balance_amount'] = $orderLogic->storeOrderSumByDate($startTime, $endTime, array_merge($where, ['pay_type' => PayEnum::BALANCE_PAY]));
//微信条码支付总金额
$data['wechat_code_amount'] = $orderLogic->storeOrderSumByDate($startTime, $endTime, array_merge($where, ['pay_type' => PayEnum::WECHAT_PAY_BARCODE]));
//支付条码支付总金额
$data['alipay_code_amount'] = $orderLogic->storeOrderSumByDate($startTime, $endTime, array_merge($where, ['pay_type' => PayEnum::ALIPAY_BARCODE]));
//线下收银总金额
$data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 3]);
$data['cashier_amount'] = $orderLogic->storeOrderSumByDate($startTime, $endTime, array_merge($where, ['shipping_type' => 3]));
//现金收银总金额
$data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price');
$data['cash_amount'] = StoreCashFinanceFlow::where($cashFinanceWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price');
//核销订单金额
$data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 2]);
$data['verify_amount'] = $orderLogic->storeOrderSumByDate($startTime, $endTime, array_merge($where, ['shipping_type' => 2]));
//门店收益金额
$data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, [], 'profit');
$data['income_amount'] = StoreFinanceFlow::where($storeFinanceWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');
//门店收款金额
$data['receipt_amount'] = UserRecharge::where([
'store_id'=>$params['store_id'],
'paid'=>YesNoEnum::YES
])->sum('price');
$data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price');
//保证金金额
$data['deposit_amount'] = StoreFinanceFlow::where($storeFinanceWhereTwo)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');
//门店成交用户数
$data['user_number'] = StoreOrder::where('store_id', $params['store_id'])
->where('paid', 1)
$data['user_number'] = StoreOrder::where($where)
->whereBetweenTime('pay_time', $startTime, $endTime)
->group('uid')
->count();
if ($dateDiff->days == 1) {
$group = 'HOUR(pay_time)';
$i = 0;
@ -92,8 +106,7 @@ class WorkbenchLogic extends BaseLogic
$i++;
}
$field = 'from_unixtime(pay_time,"%m-%d") as pay_time,sum(pay_price) as pay_price';
}
else {
} else {
$group = 'MONTH(pay_time)';
$i = 0;
$month = 0;
@ -113,15 +126,13 @@ class WorkbenchLogic extends BaseLogic
$field = 'from_unixtime(pay_time,"%Y-%m") as pay_time,sum(pay_price) as pay_price';
}
$orderList = StoreOrder::field($field)
->where('store_id', $params['store_id'])
->where('paid', 1)
->where($where)
->whereBetweenTime('pay_time', $startTime, $endTime)
->group($group)
->select()
->toArray();
$userList = StoreOrder::field($field . ',count(uid) as user_num')
->where('store_id', $params['store_id'])
->where('paid', 1)
->where($where)
->whereBetweenTime('pay_time', $startTime, $endTime)
->group($group . ',uid')
->select()
@ -151,12 +162,14 @@ class WorkbenchLogic extends BaseLogic
'user_number' => array_values($userListTmp)
]
];
$data['order_list'] = StoreOrder::with('user')->where('store_id', $params['store_id'])
->where('paid', 1)
$data['order_list'] = StoreOrder::with('user')->where($where)
->whereBetweenTime('pay_time', $startTime, $endTime)
->order('pay_time', 'desc')
->limit(10)
->select()->toArray();
->limit(6)
->select()->each(function($item){
$item->pay_time=$item->pay_time>0?date('Y-m-d H:i:s',$item->pay_time):'';
})
->toArray();
$data['pay_type'] = [
['name' => '线上收银订单', 'value' => bcsub($data['order_amount'], bcadd($data['verify_amount'], $data['cash_amount'], 2), 2)],
['name' => '核销订单', 'value' => $data['verify_amount']],
@ -550,7 +563,7 @@ class WorkbenchLogic extends BaseLogic
{
//当日营业额的统计
$today = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$params['store_id']]);
$today = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $params['store_id']]);
$turnover_today = $today
->whereDay('create_time')
->sum('pay_price');
@ -564,35 +577,34 @@ class WorkbenchLogic extends BaseLogic
->sum('cost');
//当日加到保证金的
$deposit = StoreFinanceFlow::where(['store_id'=>$params['store_id'],'status'=>YesNoEnum::YES])
->where('financial_type',OrderEnum::ORDER_MARGIN);
$deposit_today =$deposit
->whereDay('create_time')
->sum('number');
//当日的现金收银
$cash_today = StoreCashFinanceFlow::where('store_id',$params['store_id'])
$deposit = StoreFinanceFlow::where(['store_id' => $params['store_id'], 'status' => YesNoEnum::YES])
->where('financial_type', OrderEnum::ORDER_MARGIN);
$deposit_today = $deposit
->whereDay('create_time')
->where('status',YesNoEnum::YES)
->sum('number');
//当日的现金收银
$cash_today = StoreCashFinanceFlow::where('store_id', $params['store_id'])
->whereDay('create_time')
->where('status', YesNoEnum::YES)
->sum('receivable');
//总的营业额的统计 总的利润的统计 总的成本合集的统计 总的加到保证金的
$all = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$params['store_id']]);
$all = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $params['store_id']]);
$deposit_all = StoreFinanceFlow::where(['store_id'=>$params['store_id'],'status'=>YesNoEnum::YES])
$deposit_all = StoreFinanceFlow::where(['store_id' => $params['store_id'], 'status' => YesNoEnum::YES])
->sum('number');
$cash_all = StoreCashFinanceFlow::where('store_id',$params['store_id'])
->where('status',YesNoEnum::YES)
$cash_all = StoreCashFinanceFlow::where('store_id', $params['store_id'])
->where('status', YesNoEnum::YES)
->sum('receivable');
if(isset($params['month']) && $params['month']){
$all = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$params['store_id']])
->whereMonth('create_time', $params['month'])
;
$deposit_all = SystemStore::where('id',$params['store_id'])
if (isset($params['month']) && $params['month']) {
$all = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $params['store_id']])
->whereMonth('create_time', $params['month']);
$deposit_all = SystemStore::where('id', $params['store_id'])
->whereMonth('create_time', $params['month'])
->value('paid_deposit');
$cash_all = StoreCashFinanceFlow::where('store_id',$params['store_id'])
->where('status',YesNoEnum::YES)
$cash_all = StoreCashFinanceFlow::where('store_id', $params['store_id'])
->where('status', YesNoEnum::YES)
->whereMonth('create_time', $params['month'])
->sum('receivable');
}
@ -601,32 +613,31 @@ class WorkbenchLogic extends BaseLogic
$profit_all = $all
->sum('profit');
//消耗余额 V2.0
$cost_all = CapitalFlow::
where(['category'=>'user_order_balance_pay','store_id'=>$params['store_id']])
$cost_all = CapitalFlow::where(['category' => 'user_order_balance_pay', 'store_id' => $params['store_id']])
->sum('amount');
$time = self::getLastSevenDays();
$newArr = [];
foreach ($time as $value){
$data = self::dealSearch($params['store_id'],$value);
foreach ($time as $value) {
$data = self::dealSearch($params['store_id'], $value);
$newArr[$value] = $data;
}
return [
'today'=>[
'turnover_today'=>$turnover_today,
'profit_today'=>$profit_today,
'cost_today'=>$cost_today,
'deposit_today'=>$deposit_today,
'cash_today'=>$cash_today,
'today' => [
'turnover_today' => $turnover_today,
'profit_today' => $profit_today,
'cost_today' => $cost_today,
'deposit_today' => $deposit_today,
'cash_today' => $cash_today,
],
'all'=>[
'turnover_all'=>$turnover_all,
'profit_all'=>$profit_all,
'cost_all'=>$cost_all,
'deposit_all'=>$deposit_all,
'cash_all'=>$cash_all,
'all' => [
'turnover_all' => $turnover_all,
'profit_all' => $profit_all,
'cost_all' => $cost_all,
'deposit_all' => $deposit_all,
'cash_all' => $cash_all,
],
'time'=>$newArr
'time' => $newArr
];
@ -661,7 +672,6 @@ class WorkbenchLogic extends BaseLogic
->where('status',YesNoEnum::YES);
$cash_count = $cash->count();
$cash_receipt = $cash->sum('receipts');*/
}
@ -680,11 +690,11 @@ class WorkbenchLogic extends BaseLogic
}
public static function dealSearch($store_id,$startTime)
public static function dealSearch($store_id, $startTime)
{
$endTime = date('Y-m-d', strtotime($startTime) + 86400);
//当日营业额的统计 当日利润的统计 当日成本合集的统计 当日加到保证金的 当日的现金收银
$today = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$store_id]);
$today = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $store_id]);
$turnover_today = $today
->whereBetweenTime('create_time', $startTime, $endTime)
->sum('pay_price');
@ -695,33 +705,32 @@ class WorkbenchLogic extends BaseLogic
->whereBetweenTime('create_time', $startTime, $endTime)
->sum('cost');
$deposit = StoreFinanceFlow::where(['store_id'=>$store_id])
->where('financial_type',OrderEnum::ORDER_MARGIN);
$deposit_today =$deposit
$deposit = StoreFinanceFlow::where(['store_id' => $store_id])
->where('financial_type', OrderEnum::ORDER_MARGIN);
$deposit_today = $deposit
->whereBetweenTime('create_time', $startTime, $endTime)
->sum('number');
$cash_today = StoreCashFinanceFlow::where('store_id',$store_id)
$cash_today = StoreCashFinanceFlow::where('store_id', $store_id)
->whereBetweenTime('create_time', $startTime, $endTime)
->where('status',YesNoEnum::YES)
->where('status', YesNoEnum::YES)
->sum('receipts');
return [
'turnover_today'=>$turnover_today,
'profit_today'=>$profit_today,
'cost_today'=>$cost_today,
'deposit_today'=>$deposit_today,
'cash_today'=>$cash_today,
'turnover_today' => $turnover_today,
'profit_today' => $profit_today,
'cost_today' => $cost_today,
'deposit_today' => $deposit_today,
'cash_today' => $cash_today,
];
}
public static function rechargeData($params)
{
$data['receipt_amount'] = UserRecharge::where([
'store_id'=>$params['store_id'],
'paid'=>YesNoEnum::YES
'store_id' => $params['store_id'],
'paid' => YesNoEnum::YES
])->sum('price');
return $data??[];
return $data ?? [];
}
@ -746,32 +755,31 @@ class WorkbenchLogic extends BaseLogic
"series" => [
[
"name" => "商品浏览量",
"data" => self::store_visit_count($dates,$store_id),
"data" => self::store_visit_count($dates, $store_id),
"type" => "line",
"smooth" => "true",
"yAxisIndex" => 1
],
[
"name" => "商品访客量",
"data" => self::store_visit_user($dates,$store_id),
"data" => self::store_visit_user($dates, $store_id),
"type" => "line",
"smooth" => "true",
"yAxisIndex" => 1
],
[
"name" => "支付金额",
"data" => self::payPrice($dates,$store_id),
"data" => self::payPrice($dates, $store_id),
"type" => "bar"
],
[
"name" => "退款金额",
"data" => self::refundPrice($dates,$store_id),
"data" => self::refundPrice($dates, $store_id),
"type" => "bar"
]
]
];
return $data;
}
@ -779,11 +787,11 @@ class WorkbenchLogic extends BaseLogic
/**
* 商品浏览量
*/
public static function store_visit_count($dates,$store_id)
public static function store_visit_count($dates, $store_id)
{
$data = [];
foreach ($dates as $date) {
$data[] = StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->cache('store_visit_count_' . $date, 300)->sum('count');
$data[] = StoreVisit::whereDay('create_time', $date)->where('store_id', $store_id)->cache('store_visit_count_' . $date, 300)->sum('count');
}
return $data;
}
@ -792,11 +800,11 @@ class WorkbenchLogic extends BaseLogic
/**
* 商品浏览量
*/
public static function store_visit_user($dates,$store_id)
public static function store_visit_user($dates, $store_id)
{
$data = [];
foreach ($dates as $date) {
$data[] = StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->cache('store_visit_user_' . $date, 300)->count('uid');
$data[] = StoreVisit::whereDay('create_time', $date)->where('store_id', $store_id)->cache('store_visit_user_' . $date, 300)->count('uid');
}
return $data;
}
@ -805,11 +813,11 @@ class WorkbenchLogic extends BaseLogic
/**
* 支付金额
*/
public static function payPrice($dates,$store_id)
public static function payPrice($dates, $store_id)
{
$data = [];
foreach ($dates as $date) {
$data[] = StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->cache('payPrice_' . $date, 300)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
$data[] = StoreOrder::whereDay('create_time', $date)->where('store_id', $store_id)->cache('payPrice_' . $date, 300)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
}
return $data;
}
@ -818,11 +826,11 @@ class WorkbenchLogic extends BaseLogic
/**
* 退款金额
*/
public static function refundPrice($dates,$store_id)
public static function refundPrice($dates, $store_id)
{
$data = [];
foreach ($dates as $date) {
$data[] = StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->where('status', 'in', [-1, -2])->cache('refundPrice_' . $date, 300)->where('paid', 1)->sum('pay_price');
$data[] = StoreOrder::whereDay('create_time', $date)->where('store_id', $store_id)->where('status', 'in', [-1, -2])->cache('refundPrice_' . $date, 300)->where('paid', 1)->sum('pay_price');
}
return $data;
}
@ -832,10 +840,46 @@ class WorkbenchLogic extends BaseLogic
/**
* 获取商品排名数据
*/
public static function get_product_ranking($where)
public static function get_product_ranking($where, $store_id)
{
return (new ProductStatisticLogic())->get_product_ranking($where);
return self::product_ranking($where, $store_id);
}
public static function product_ranking($where, $store_id)
{
$time = explode('-', $where['create_time']);
$time = [strtotime($time[0]), strtotime($time[1])];
$list = StoreProductLog::whereBetweenTime('create_time', $time[0], $time[1])
->where('store_id', $store_id)
->field([
'store_id',
'product_id',
'SUM(visit_num) as visit',
'COUNT(distinct(uid)) as user',
'SUM(cart_num) as cart',
'SUM(order_num) as orders',
'SUM(pay_num) as pay',
'SUM(pay_price * pay_num) as price',
'SUM(cost_price) as cost',
'ROUND((SUM(pay_price)-SUM(cost_price))/SUM(pay_price),2) as profit',
'SUM(collect_num) as collect',
'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes',
'COUNT(distinct(pay_uid))-1 as repeats'
])->group('product_id')->order('pay', ' desc')->limit(20)->select()->toArray();
foreach ($list as $key => &$item) {
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find();
$item['store_name'] = $find['store_name'];
$item['image'] = $find['image'];
if ($item['profit'] == null) $item['profit'] = 0;
if ($item['changes'] == null) $item['changes'] = 0;
if ($item['repeats'] == null) {
$item['repeats'] = 0;
} else {
$item['repeats'] = bcdiv(count(StoreProductLog::where($where)->where('type', 'pay')->where('product_id', $item['product_id'])->where('store_id', $store_id)->field('count(pay_uid) as p')->group('pay_uid')->having('p>1')->select()), $item['repeats'], 2);
}
}
return array_merge($list);
}
}

View File

@ -23,6 +23,7 @@ class StoreOrderValidate extends BaseValidate
'verify_code' => 'requireWithout:id',
'uid' => 'require|number',
'cart_id' => 'require|array',
'type' => 'require|number',
];
@ -33,6 +34,7 @@ class StoreOrderValidate extends BaseValidate
protected $field = [
'id' => 'id',
'verify_code' => '核销码',
'type' => '发送短信类型',
];
@ -85,7 +87,7 @@ class StoreOrderValidate extends BaseValidate
public function sceneCheck()
{
return $this->only(['uid','cart_id']);
return $this->only(['uid','cart_id','type']);
}
}

View File

@ -25,7 +25,7 @@
},
"require": {
"php": ">=8.1",
"workerman/webman-framework": "v1.5.16",
"workerman/webman-framework": "v1.5.19",
"monolog/monolog": "^2.2",
"webman/think-orm": "v1.1.1",
"vlucas/phpdotenv": "^5.4",
@ -48,7 +48,7 @@
"next/var-dumper": "^0.1.0",
"w7corp/easywechat": "^6.8",
"hyperf/pimple": "~2.2.0",
"yansongda/pay": "~3.7.3",
"yansongda/pay": "v3.7.7",
"webman/redis-queue": "^1.3",
"webman/push": "^1.0",
"ext-bcmath": "*",

1398
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +0,0 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
ignorePatterns: ['/auto-imports.d.ts', '/components.d.ts'],
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript/recommended',
'@vue/eslint-config-prettier',
'./.eslintrc-auto-import.json'
],
rules: {
'prettier/prettier': [
'warn',
{
semi: false,
singleQuote: true,
printWidth: 100,
proseWrap: 'preserve',
bracketSameLine: false,
endOfLine: 'lf',
tabWidth: 4,
useTabs: false,
trailingComma: 'none'
}
],
'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-undef': 'off',
'vue/prefer-import-from-vue': 'off',
'no-prototype-builtins': 'off',
'prefer-spread': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off'
},
globals: {
module: 'readonly'
}
}

View File

@ -1,36 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
# unplugin-auto-import
auto-imports.d.ts
components.d.ts
.eslintrc-auto-import.json
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# .env
.env.development
.env.production
helper.json

View File

@ -1,3 +0,0 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}

View File

@ -1,11 +0,0 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"css.validate": false,
"less.validate": false,
"scss.validate": false
}

View File

@ -1,46 +0,0 @@
# vue-project
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```

View File

@ -1,234 +0,0 @@
<!-- 订单详情 -->
<template>
<el-drawer v-model="showDetail" direction="rtl" :destroy-on-close="true" title="订单详情" size="50%">
<template #header>
<h4>订单详情</h4>
</template>
<template #default>
<!-- head -->
<div class="flex">
<el-image class="w-[50px] h-[50px]" :src="url" :fit="fit" />
<div class="flex flex-col ml-3 justify-between">
<div style="font-size:16px">
{{ orderType ? '【收银订单】' : '售后订单' }}
</div>
<div>
订单编号 {{ detailData.order_id }}
</div>
</div>
</div>
<ul class="flex justify-between w-[70%] mt-[20px]">
<li>
<div>订单状态</div>
<div>{{ orderType ? detailData.status_name : detailData.refund_status_name }}</div>
</li>
<li>
<div>实际支付</div>
<div>{{ detailData.pay_price }}</div>
</li>
<li>
<div>支付方式</div>
<div>{{ detailData.pay_type }}</div>
</li>
<li v-if="orderType">
<div>支付时间</div>
<div>{{ detailData.pay_time }}</div>
</li>
<li v-if="!orderType">
<div>退款件数</div>
<!-- <div>{{ detailData.pay_time }}</div> -->
</li>
<li v-if="!orderType">
<div>退款时间</div>
<!-- <div>{{ detailData.pay_time }}</div> -->
</li>
</ul>
<!-- content -->
<el-tabs v-model="activeName" class="mt-[20px]">
<el-tab-pane label="订单信息" name="first">
<el-descriptions :column="3" border :title="item.title" class="mb-[30px]"
v-for="(item, index) in orderInfoCongig" :key="index" v-show="item.isShow">
<el-descriptions-item :label="el.name" label-class-name="my-label" v-for="el in item.child">
{{ el.value }}
</el-descriptions-item>
</el-descriptions>
</el-tab-pane>
<el-tab-pane label="商品信息" name="second">
<el-table border :data="detailData.product">
<el-table-column label="商品信息" prop="build_area_text" show-overflow-tooltip>
<template #default="{ row }">
<div class="flex w-[300px] items-center">
<el-image class="w-[50px] h-[50px] mr-2" :src="row.cart_info.image" />
<span> {{ row.cart_info.name }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="价格" prop="cart_info.price" show-overflow-tooltip />
<el-table-column label="数量" prop="cart_info.cart_num" show-overflow-tooltip width="120" />
<el-table-column label="小计" prop="cart_info.total" show-overflow-tooltip />
</el-table>
</el-tab-pane>
<!-- <el-tab-pane label="订单记录" name="third">
<el-table border :data="formData.detail2">
<el-table-column label="订单id" prop="project_level_text" show-overflow-tooltip />
<el-table-column label="操作记录" prop="total_investment" show-overflow-tooltip width="120" />
<el-table-column label="操作时间" prop="engineering_status_text" show-overflow-tooltip />
</el-table>
</el-tab-pane> -->
</el-tabs>
</template>
</el-drawer>
</template>
<script lang="ts" setup>
import { ref, reactive, defineEmits, defineProps, onMounted } from "vue"
const showDetail = ref(false)
const url =
'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
const props = defineProps({
detailData: {
type: Object,
},
// 0退1
orderType: {
type: Number,
default: 1,
}
})
const orderInfoCongig = ref(
[
{
title: '退款原因',
isShow: props.orderType == 0,
child: [
{
name: "退款原因",
value: props.detailData?.refund_reason
},
{
name: "退款金额",
value: props.detailData?.refund_price
},
{
name: "退款说明",
value: props.detailData?.refund_reason_wap_explain
},
// {
// name: "退",
// value: props.detailData?.mobile
// },
]
},
{
title: '用户信息',
isShow: true,
child: [
{
name: "用户昵称",
value: props.detailData?.nickname
},
{
name: "绑定电话",
value: props.detailData?.mobile
},
]
},
{
title: '收货人信息',
isShow: true,
child: [
{
name: "收货人",
value: props.detailData?.real_name
},
{
name: "收获电话",
value: props.detailData?.user_phone
},
{
name: "收获地址",
value: props.detailData?.user_address
},
]
},
{
title: '订单信息',
isShow: true,
child: [
{
name: "创建时间",
value: props.detailData?.create_time
},
{
name: "商品总数",
value: props.detailData?.total_num
},
{
name: "商品总价",
value: props.detailData?.total_price
},
{
name: "店员名称",
value: props.detailData?.staff_name
},
// {
// name: "",
// value: " props.detailData?.total_num"
// },
{
name: "支付时间",
value: props.detailData?.pay_time
},
{
name: "支付方式",
value: props.detailData?.pay_type
},
]
},
{
title: '订单备注',
isShow: true,
child: [
{
name: "备注",
value: props.detailData?.remark
},
]
},
])
const activeName = 'first'
const open = () => {
showDetail.value = true
}
const close = () => {
showDetail.value = false
}
defineExpose({
open,
close
})
</script>

View File

@ -1,170 +0,0 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form class="mb-[-16px]" :model="queryParams" label-width="80px">
<el-row>
<el-col :span="6">
<el-form-item label="时间筛选">
<el-date-picker v-model="date" type="daterange" range-separator="-" start-placeholder="开始时间"
end-placeholder="结束时间" value-format="YYYY-MM-DD" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="店员">
<el-select class="flex-1" v-model="queryParams.staff_id" placeholder="请选择店员">
<el-option :label="item.staff_name" :value="item.id" v-for="(item, index) in staffList" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="用户搜索">
<el-input v-model="queryParams.order_id" clearable placeholder="请输入订单编号" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" @click="handleResetPage">查询</el-button>
<el-button @click="handleResetParams">重置</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists">
<el-table-column label="订单号" prop="order_id" show-overflow-tooltip />
<el-table-column label="用户信息" prop="build_area_text" show-overflow-tooltip>
<template #default="{ row }">
<div class="flex items-center">
<el-image style="width: 50px; height: 50px" :src="row.avatar" class="mr-2" />
{{ row.nickname }}
</div>
</template>
</el-table-column>
<el-table-column label="支付金额" prop="" show-overflow-tooltip />
<el-table-column label="充值类型" prop="" show-overflow-tooltip />
<el-table-column label="支付时间" prop="" show-overflow-tooltip />
<el-table-column label="关联店员" prop="" show-overflow-tooltip />
<el-table-column label="操作" width="170" fixed="right">
<template #default="{ row }">
<el-button type="primary" link @click="handleRe(row)">
备注
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<el-dialog title="添加备注" v-model="showDialog" width="550px">
<el-form-item>
<el-input v-model="remarks" type="textarea" placeholder="请输入备注内容"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleRemarks">确定</el-button>
<el-button @click="showDialog = false">取消</el-button>
</el-form-item>
</el-dialog>
</div>
</template>
<script lang="ts" setup name="manageProjectLists">
import orderDetail from './../../components/orderDetail/index.vue'
import { ref, reactive } from 'vue'
import { usePaging } from '@/hooks/usePaging'
import { apiStoreOrderLists, apiStoreOrderDetail, apiStoreOrderTitle } from '@/api/store_order'
import feedback from '@/utils/feedback'
//
const queryParams = reactive({
order_id: "",
pay_type: "",
start_time: "",
end_time: '',
status: "",
staff_id: ""
})
const date = ref([])
const showDetail = ref(false)
//
const handleWriteOff = async (id: number) => {
await feedback.confirm('确定要核销订单吗?')
// await adminDelete({ id })
getLists()
}
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiStoreOrderLists,
params: queryParams
})
const handleResetPage = () => {
if (date.value.length) {
queryParams.start_time = date.value[0]
queryParams.end_time = date.value[1]
}
resetPage()
}
const handleResetParams = () => {
date.value = []
resetParams()
}
const detailRef = ref(null)
const detailData = ref({})
//
const handleDetail = async (id: any) => {
let res = await apiStoreOrderDetail({ id })
console.log(res)
detailData.value = res
showDetail.value = true
await nextTick()
detailRef.value.open()
}
const payTypeList = ref([])
const staffList = ref([])
const order_status = ref({
finish: '',
wait_receive: '',
wait_send: ""
})
const getTitle = async () => {
let res = await await apiStoreOrderTitle()
payTypeList.value = res.pay_type
staffList.value = res.staff
order_status.value = res.order_status
}
// getTitle()
const showDialog = ref(false)
const remarks = ref('')
const rows = ref({})
const handleRe = (row) => {
showDialog.value = true
rows.value = row
}
const handleRemarks = async (row: any) => {
await apiStorFinanceFlowRemarks({ row })
showDialog.value = false
}
getLists()
</script>

View File

@ -1,24 +0,0 @@
import request from '@/utils/request'
export function apiStoreOrderLists(params: any) {
return request.get({ url: '/store_order/storeOrder/lists', params })
}
export function apiStoreOrderTitle() {
return request.get({ url: '/store_order/storeOrder/title' })
}
export function apiStoreOrderDetail(params: any) {
return request.get({ url: '/store_order/storeOrder/detail', params })
}
export function apiStoreRefundOrderLists(params: any) {
return request.get({ url: '/store_order/storeRefundOrder/lists', params })
}
export function apiStoreRefundOrderDetail(params: any) {
return request.get({ url: '/store_order/storeRefundOrder/detail', params })
}

View File

@ -1 +0,0 @@
import o from"./error.195a6a92.js";import{d as r,o as i,c as p,W as m,O as e,a as t}from"./@vue.c3e77981.js";import"./element-plus.eb2e53ea.js";import"./@vueuse.a48d0173.js";import"./@element-plus.12c58ce2.js";import"./lodash-es.2b5acb28.js";import"./dayjs.16ed1fda.js";import"./axios.a8078129.js";import"./async-validator.fb49d0f5.js";import"./@ctrl.b082b0c1.js";import"./@popperjs.36402333.js";import"./escape-html.e5dfadb9.js";import"./normalize-wheel-es.8aeb3683.js";import"./vue-router.995b143f.js";import"./index.0c584682.js";import"./lodash.a2abcd4b.js";import"./pinia.b5130627.js";import"./css-color-function.975e80a5.js";import"./color.d986aa86.js";import"./clone.704d8332.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./ms.564e106c.js";import"./nprogress.ded7f805.js";import"./vue-clipboard3.987889a8.js";import"./clipboard.af74a91f.js";import"./echarts.8535e5a6.js";import"./zrender.3eba8991.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b8b719e9.js";const s="/storePage/assets/no_perms.a56e95a5.png",a={class:"error404"},u=t("div",{class:"flex justify-center"},[t("img",{class:"w-[150px] h-[150px]",src:s,alt:""})],-1),R=r({__name:"403",setup(c){return(n,_)=>(i(),p("div",a,[m(o,{code:"403",title:"\u60A8\u7684\u8D26\u53F7\u6743\u9650\u4E0D\u8DB3\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650\uFF01","show-btn":!1},{content:e(()=>[u]),_:1})]))}});export{R as default};

View File

@ -1 +0,0 @@
import o from"./error.195a6a92.js";import{d as r,o as t,c as m,W as p}from"./@vue.c3e77981.js";import"./element-plus.eb2e53ea.js";import"./@vueuse.a48d0173.js";import"./@element-plus.12c58ce2.js";import"./lodash-es.2b5acb28.js";import"./dayjs.16ed1fda.js";import"./axios.a8078129.js";import"./async-validator.fb49d0f5.js";import"./@ctrl.b082b0c1.js";import"./@popperjs.36402333.js";import"./escape-html.e5dfadb9.js";import"./normalize-wheel-es.8aeb3683.js";import"./vue-router.995b143f.js";import"./index.0c584682.js";import"./lodash.a2abcd4b.js";import"./pinia.b5130627.js";import"./css-color-function.975e80a5.js";import"./color.d986aa86.js";import"./clone.704d8332.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./ms.564e106c.js";import"./nprogress.ded7f805.js";import"./vue-clipboard3.987889a8.js";import"./clipboard.af74a91f.js";import"./echarts.8535e5a6.js";import"./zrender.3eba8991.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b8b719e9.js";const i={class:"error404"},M=r({__name:"404",setup(e){return(u,c)=>(t(),m("div",i,[p(o,{code:"404",title:"\u54CE\u5440\uFF0C\u51FA\u9519\u4E86\uFF01\u60A8\u8BBF\u95EE\u7684\u9875\u9762\u4E0D\u5B58\u5728\u2026"})]))}});export{M as default};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
import{c as u}from"./highlight.js.31cd7941.js";import{d as c,r as d,w as s,b as t,h as g}from"./@vue.c3e77981.js";var i=c({props:{code:{type:String,required:!0},language:{type:String,default:""},autodetect:{type:Boolean,default:!0},ignoreIllegals:{type:Boolean,default:!0}},setup:function(e){var a=d(e.language);s(function(){return e.language},function(n){a.value=n});var r=t(function(){return e.autodetect||!a.value}),o=t(function(){return!r.value&&!u.getLanguage(a.value)});return{className:t(function(){return o.value?"":"hljs "+a.value}),highlightedCode:t(function(){var n;if(o.value)return console.warn('The language "'+a.value+'" you specified could not be found.'),e.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;");if(r.value){var l=u.highlightAuto(e.code);return a.value=(n=l.language)!==null&&n!==void 0?n:"",l.value}return(l=u.highlight(e.code,{language:a.value,ignoreIllegals:e.ignoreIllegals})).value})}},render:function(){return g("pre",{},[g("code",{class:this.className,innerHTML:this.highlightedCode})])}}),f={install:function(e){e.component("highlightjs",i)},component:i};export{f as o};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
import"./account-adjust.vue_vue_type_script_setup_true_lang.9e8e32f0.js";import{_ as K}from"./account-adjust.vue_vue_type_script_setup_true_lang.9e8e32f0.js";import"./element-plus.eb2e53ea.js";import"./@vue.c3e77981.js";import"./@vueuse.a48d0173.js";import"./@element-plus.12c58ce2.js";import"./lodash-es.2b5acb28.js";import"./dayjs.16ed1fda.js";import"./axios.a8078129.js";import"./async-validator.fb49d0f5.js";import"./@ctrl.b082b0c1.js";import"./@popperjs.36402333.js";import"./escape-html.e5dfadb9.js";import"./normalize-wheel-es.8aeb3683.js";import"./index.4f18ffd6.js";import"./index.0c584682.js";import"./lodash.a2abcd4b.js";import"./vue-router.995b143f.js";import"./pinia.b5130627.js";import"./css-color-function.975e80a5.js";import"./color.d986aa86.js";import"./clone.704d8332.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./ms.564e106c.js";import"./nprogress.ded7f805.js";import"./vue-clipboard3.987889a8.js";import"./clipboard.af74a91f.js";import"./echarts.8535e5a6.js";import"./zrender.3eba8991.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b8b719e9.js";export{K as default};

View File

@ -1 +0,0 @@
import{D as B,G as R,H as g,C as N,F as q}from"./element-plus.eb2e53ea.js";import{P as A}from"./index.4f18ffd6.js";import{f as C}from"./index.0c584682.js";import{d as I,s as D,a0 as U,b as j,w as b,o as G,M,O as a,a as P,W as o,u as r,T as n,U as E}from"./@vue.c3e77981.js";const S={class:"pr-8"},z=I({__name:"account-adjust",props:{show:{type:Boolean,required:!0},value:{type:[Number,String],required:!0}},emits:["update:show","confirm"],setup(d,{emit:w}){const s=D(),i=d,c=w,u=U({action:1,num:"",remark:""}),m=D(),f=j(()=>Number(i.value)+Number(u.num)*(u.action==1?1:-1)),v={num:[{required:!0,message:"\u8BF7\u8F93\u5165\u8C03\u6574\u7684\u91D1\u989D"}]},y=e=>{if(e.includes("-"))return C.msgError("\u8BF7\u8F93\u5165\u6B63\u6574\u6570");u.num=e},V=async()=>{var e;await((e=s.value)==null?void 0:e.validate()),c("confirm",u)},h=()=>{var e;c("update:show",!1),(e=s.value)==null||e.resetFields()};return b(()=>i.show,e=>{var l,t;e?(l=m.value)==null||l.open():(t=m.value)==null||t.close()}),b(f,e=>{e<0&&(C.msgError("\u8C03\u6574\u540E\u4F59\u989D\u9700\u5927\u4E8E0"),u.num="")}),(e,l)=>{const t=B,_=R,k=g,F=N,x=q;return G(),M(A,{ref_key:"popupRef",ref:m,title:"\u4F59\u989D\u8C03\u6574",width:"500px",onConfirm:V,async:!0,onClose:h},{default:a(()=>[P("div",S,[o(x,{ref_key:"formRef",ref:s,model:r(u),"label-width":"120px",rules:v},{default:a(()=>[o(t,{label:"\u5F53\u524D\u4F59\u989D"},{default:a(()=>[n("\xA5 "+E(d.value),1)]),_:1}),o(t,{label:"\u4F59\u989D\u589E\u51CF",required:"",prop:"action"},{default:a(()=>[o(k,{modelValue:r(u).action,"onUpdate:modelValue":l[0]||(l[0]=p=>r(u).action=p)},{default:a(()=>[o(_,{label:1},{default:a(()=>[n("\u589E\u52A0\u4F59\u989D")]),_:1}),o(_,{label:2},{default:a(()=>[n("\u6263\u51CF\u4F59\u989D")]),_:1})]),_:1},8,["modelValue"])]),_:1}),o(t,{label:"\u8C03\u6574\u4F59\u989D",prop:"num"},{default:a(()=>[o(F,{"model-value":r(u).num,placeholder:"\u8BF7\u8F93\u5165\u8C03\u6574\u7684\u91D1\u989D",type:"number",onInput:y},null,8,["model-value"])]),_:1}),o(t,{label:"\u8C03\u6574\u540E\u4F59\u989D"},{default:a(()=>[n(" \xA5 "+E(r(f)),1)]),_:1}),o(t,{label:"\u5907\u6CE8",prop:"remark"},{default:a(()=>[o(F,{modelValue:r(u).remark,"onUpdate:modelValue":l[1]||(l[1]=p=>r(u).remark=p),type:"textarea",rows:4},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])])]),_:1},512)}}});export{z as _};

View File

@ -1 +0,0 @@
import"./add-nav.vue_vue_type_script_setup_true_lang.66aa8291.js";import{_ as X}from"./add-nav.vue_vue_type_script_setup_true_lang.66aa8291.js";import"./element-plus.eb2e53ea.js";import"./@vue.c3e77981.js";import"./@vueuse.a48d0173.js";import"./@element-plus.12c58ce2.js";import"./lodash-es.2b5acb28.js";import"./dayjs.16ed1fda.js";import"./axios.a8078129.js";import"./async-validator.fb49d0f5.js";import"./@ctrl.b082b0c1.js";import"./@popperjs.36402333.js";import"./escape-html.e5dfadb9.js";import"./normalize-wheel-es.8aeb3683.js";import"./index.37847052.js";import"./index.0c584682.js";import"./lodash.a2abcd4b.js";import"./vue-router.995b143f.js";import"./pinia.b5130627.js";import"./css-color-function.975e80a5.js";import"./color.d986aa86.js";import"./clone.704d8332.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./ms.564e106c.js";import"./nprogress.ded7f805.js";import"./vue-clipboard3.987889a8.js";import"./clipboard.af74a91f.js";import"./echarts.8535e5a6.js";import"./zrender.3eba8991.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b8b719e9.js";import"./picker.9b3f468c.js";import"./index.vue_vue_type_script_setup_true_lang.f75f9565.js";import"./usePaging.d25ebf19.js";import"./article.e1e9cb39.js";import"./index.4f18ffd6.js";import"./picker.fe878da2.js";import"./index.5b4904fe.js";import"./index.8af6577e.js";import"./index.vue_vue_type_script_setup_true_lang.3f1a76de.js";import"./vue3-video-play.4813c60b.js";import"./vuedraggable.5825c4b1.js";import"./vue.74758107.js";import"./sortablejs.275d9d20.js";export{X as default};

Some files were not shown because too many files have changed in this diff Show More