commit
18da768909
@ -15,6 +15,8 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\logic\WorkbenchLogic;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* 工作台
|
||||
@ -232,16 +234,16 @@ class WorkbenchController extends BaseAdminController
|
||||
*/
|
||||
public function get_basic()
|
||||
{
|
||||
$startTime=$this->request->get('start_time');//开始时间
|
||||
$endTime=$this->request->get('end_time');//结束时间
|
||||
if(empty($startTime)){//如果没有传开始时间,则默认获取最近7天的数据
|
||||
$startTime=strtotime(date('Y-m-d'));
|
||||
$endTime=$startTime+86400;
|
||||
$startTime = $this->request->get('start_time'); //开始时间
|
||||
$endTime = $this->request->get('end_time'); //结束时间
|
||||
if (empty($startTime)) { //如果没有传开始时间,则默认获取最近7天的数据
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
$endTime = $startTime + 86400;
|
||||
}
|
||||
$where=[
|
||||
['create_time','between',[$startTime,$endTime]]
|
||||
$where = [
|
||||
['create_time', 'between', [$startTime, $endTime]]
|
||||
];
|
||||
$data=WorkbenchLogic::get_basic($where);
|
||||
$data = WorkbenchLogic::get_basic($where);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
@ -250,186 +252,41 @@ 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');
|
||||
}
|
||||
$data = [
|
||||
"xAxis" => [
|
||||
"2024-05-06",
|
||||
"2024-05-07",
|
||||
"2024-05-08",
|
||||
"2024-05-09",
|
||||
"2024-05-10",
|
||||
"2024-05-11",
|
||||
"2024-05-12",
|
||||
"2024-05-13",
|
||||
"2024-05-14",
|
||||
"2024-05-15",
|
||||
"2024-05-16",
|
||||
"2024-05-17",
|
||||
"2024-05-18",
|
||||
"2024-05-19",
|
||||
"2024-05-20",
|
||||
"2024-05-21",
|
||||
"2024-05-22",
|
||||
"2024-05-23",
|
||||
"2024-05-24",
|
||||
"2024-05-25",
|
||||
"2024-05-26",
|
||||
"2024-05-27",
|
||||
"2024-05-28",
|
||||
"2024-05-29",
|
||||
"2024-05-30",
|
||||
"2024-05-31",
|
||||
"2024-06-01",
|
||||
"2024-06-02",
|
||||
"2024-06-03",
|
||||
"2024-06-04"
|
||||
],
|
||||
"xAxis" => $dates,
|
||||
"series" => [
|
||||
[
|
||||
"name" => "商品浏览量",
|
||||
"data" => [
|
||||
131,
|
||||
275,
|
||||
137,
|
||||
100,
|
||||
221,
|
||||
76,
|
||||
64,
|
||||
83,
|
||||
161,
|
||||
125,
|
||||
120,
|
||||
971,
|
||||
169,
|
||||
84,
|
||||
68,
|
||||
153,
|
||||
470,
|
||||
1310,
|
||||
621,
|
||||
827,
|
||||
113,
|
||||
595,
|
||||
485,
|
||||
484,
|
||||
535,
|
||||
227,
|
||||
714,
|
||||
144,
|
||||
1159,
|
||||
731
|
||||
],
|
||||
"data" => WorkbenchLogic::store_visit_count($dates),
|
||||
"type" => "line",
|
||||
"smooth" => "true",
|
||||
"yAxisIndex" => 1
|
||||
],
|
||||
[
|
||||
"name" => "商品访客量",
|
||||
"data" => [
|
||||
21,
|
||||
26,
|
||||
26,
|
||||
32,
|
||||
26,
|
||||
14,
|
||||
6,
|
||||
13,
|
||||
17,
|
||||
26,
|
||||
24,
|
||||
18,
|
||||
7,
|
||||
6,
|
||||
23,
|
||||
23,
|
||||
23,
|
||||
33,
|
||||
29,
|
||||
61,
|
||||
25,
|
||||
103,
|
||||
55,
|
||||
45,
|
||||
45,
|
||||
30,
|
||||
28,
|
||||
25,
|
||||
41,
|
||||
21
|
||||
],
|
||||
"data" => WorkbenchLogic::store_visit_user($dates),
|
||||
"type" => "line",
|
||||
"smooth" => "true",
|
||||
"yAxisIndex" => 1
|
||||
],
|
||||
[
|
||||
"name" => "支付金额",
|
||||
"data" => [
|
||||
53.6,
|
||||
0.25,
|
||||
1231.84,
|
||||
0.8,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
0.66,
|
||||
7919.2,
|
||||
0,
|
||||
8040.38,
|
||||
0.01,
|
||||
0,
|
||||
0,
|
||||
10.49,
|
||||
0,
|
||||
0.01,
|
||||
599.01,
|
||||
100100,
|
||||
908.81,
|
||||
0,
|
||||
1887.06,
|
||||
588,
|
||||
184.3,
|
||||
665.11,
|
||||
0,
|
||||
0,
|
||||
219.2,
|
||||
24.09,
|
||||
16.99
|
||||
],
|
||||
"data" => WorkbenchLogic::payPrice($dates),
|
||||
"type" => "bar"
|
||||
],
|
||||
[
|
||||
"name" => "退款金额",
|
||||
"data" => [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
730.8,
|
||||
49,
|
||||
219,
|
||||
0,
|
||||
1323.01,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"data" => WorkbenchLogic::refundPrice($dates),
|
||||
"type" => "bar"
|
||||
]
|
||||
]
|
||||
@ -462,44 +319,6 @@ class WorkbenchController extends BaseAdminController
|
||||
"stock" => 16777213,
|
||||
"is_show" => 1
|
||||
],
|
||||
[
|
||||
"product_id" => 1670,
|
||||
"visit" => "949",
|
||||
"user" => 161,
|
||||
"cart" => "20",
|
||||
"orders" => "47",
|
||||
"pay" => "34",
|
||||
"price" => "4347.45",
|
||||
"cost" => "0.00",
|
||||
"profit" => "1.00",
|
||||
"collect" => "2",
|
||||
"changes" => "0.13",
|
||||
"repeats" => "0.14",
|
||||
"store_name" => "ECOK2024年春秋季美式复古美拉德风高级感撞色领拉链夹克外套女潮",
|
||||
"image" => "https://multi-store.crmeb.net/uploads/attach/2024/02/19/5bf089c30da5bdddd815fbf2cba148e6.jpg",
|
||||
"product_price" => "169.90",
|
||||
"stock" => 2980,
|
||||
"is_show" => 1
|
||||
],
|
||||
[
|
||||
"product_id" => 2033,
|
||||
"visit" => "743",
|
||||
"user" => 139,
|
||||
"cart" => "30",
|
||||
"orders" => "52",
|
||||
"pay" => "20",
|
||||
"price" => "3930.50",
|
||||
"cost" => "0.00",
|
||||
"profit" => "1.00",
|
||||
"collect" => "1",
|
||||
"changes" => "0.04",
|
||||
"repeats" => "0.50",
|
||||
"store_name" => "【618抢先购】CT四色眼影盘新色枕边话哑光亮片粉棕彩妆官方正品",
|
||||
"image" => "https://multi-store.crmeb.net/uploads/attach/2024/05/24/fc63ee052b9dc66bd70a1e013510ded2.jpg",
|
||||
"product_price" => "490.00",
|
||||
"stock" => 139994,
|
||||
"is_show" => 1
|
||||
],
|
||||
];
|
||||
return $this->data($data);
|
||||
}
|
||||
@ -798,6 +617,23 @@ class WorkbenchController extends BaseAdminController
|
||||
//当日订单金额
|
||||
public function top_trade()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
$times = date('Y-m-d');
|
||||
$yesterday= date('Y-m-d', strtotime('-1 day'));
|
||||
$dates_two=[];
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$dates_two[]=[$times." ".$i.":00:00",$times." ".$i.":59:59"];
|
||||
}
|
||||
$data = [
|
||||
"left" => [
|
||||
"name" => "当日订单金额",
|
||||
@ -829,66 +665,8 @@ class WorkbenchController extends BaseAdminController
|
||||
"24"
|
||||
],
|
||||
"series" => [
|
||||
[
|
||||
"money" => 279.47,
|
||||
"value" => [
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"4.48",
|
||||
"257.20",
|
||||
"0.00",
|
||||
"16.99",
|
||||
"0.80",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00"
|
||||
]
|
||||
],
|
||||
[
|
||||
"money" => 10175.64,
|
||||
"value" => [
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.01",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"40.00",
|
||||
"0.10",
|
||||
"9938.00",
|
||||
"0.08",
|
||||
"30.16",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"0.00",
|
||||
"163.20",
|
||||
"4.09",
|
||||
"0.00",
|
||||
"0.00"
|
||||
]
|
||||
]
|
||||
WorkbenchLogic::day_order_pay_price($dates_two,$times),
|
||||
WorkbenchLogic::day_order_pay_price($dates_two,$yesterday),
|
||||
]
|
||||
],
|
||||
"right" => [
|
||||
@ -921,151 +699,13 @@ class WorkbenchController extends BaseAdminController
|
||||
"24"
|
||||
],
|
||||
"series" => [
|
||||
[
|
||||
"name" => "今日订单数",
|
||||
"now_money" => 8,
|
||||
"last_money" => 13,
|
||||
"rate" => "-38.46",
|
||||
"value" => [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
],
|
||||
[
|
||||
"name" => "今日支付人数",
|
||||
"now_money" => 5,
|
||||
"last_money" => 8,
|
||||
"rate" => "-37.50",
|
||||
"value" => [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
]
|
||||
WorkbenchLogic::day_order_count($dates_two,'今日订单数'),
|
||||
WorkbenchLogic::day_order_user($dates_two,'今日支付人数'),
|
||||
]
|
||||
],
|
||||
"month" => [
|
||||
[
|
||||
"name" => "本月订单数",
|
||||
"now_money" => 30,
|
||||
"last_money" => 285,
|
||||
"rate" => "-89.47",
|
||||
"value" => [
|
||||
"2024-06-01" => 2,
|
||||
"2024-06-02" => 7,
|
||||
"2024-06-03" => 13,
|
||||
"2024-06-04" => 8,
|
||||
"2024-06-05" => 0,
|
||||
"2024-06-06" => 0,
|
||||
"2024-06-07" => 0,
|
||||
"2024-06-08" => 0,
|
||||
"2024-06-09" => 0,
|
||||
"2024-06-10" => 0,
|
||||
"2024-06-11" => 0,
|
||||
"2024-06-12" => 0,
|
||||
"2024-06-13" => 0,
|
||||
"2024-06-14" => 0,
|
||||
"2024-06-15" => 0,
|
||||
"2024-06-16" => 0,
|
||||
"2024-06-17" => 0,
|
||||
"2024-06-18" => 0,
|
||||
"2024-06-19" => 0,
|
||||
"2024-06-20" => 0,
|
||||
"2024-06-21" => 0,
|
||||
"2024-06-22" => 0,
|
||||
"2024-06-23" => 0,
|
||||
"2024-06-24" => 0,
|
||||
"2024-06-25" => 0,
|
||||
"2024-06-26" => 0,
|
||||
"2024-06-27" => 0,
|
||||
"2024-06-28" => 0,
|
||||
"2024-06-29" => 0,
|
||||
"2024-06-30" => 0
|
||||
]
|
||||
],
|
||||
[
|
||||
"name" => "本月支付人数",
|
||||
"now_money" => 15,
|
||||
"last_money" => 79,
|
||||
"rate" => "-81.01",
|
||||
"value" => [
|
||||
"2024-06-01" => 1,
|
||||
"2024-06-02" => 4,
|
||||
"2024-06-03" => 8,
|
||||
"2024-06-04" => 5,
|
||||
"2024-06-05" => 0,
|
||||
"2024-06-06" => 0,
|
||||
"2024-06-07" => 0,
|
||||
"2024-06-08" => 0,
|
||||
"2024-06-09" => 0,
|
||||
"2024-06-10" => 0,
|
||||
"2024-06-11" => 0,
|
||||
"2024-06-12" => 0,
|
||||
"2024-06-13" => 0,
|
||||
"2024-06-14" => 0,
|
||||
"2024-06-15" => 0,
|
||||
"2024-06-16" => 0,
|
||||
"2024-06-17" => 0,
|
||||
"2024-06-18" => 0,
|
||||
"2024-06-19" => 0,
|
||||
"2024-06-20" => 0,
|
||||
"2024-06-21" => 0,
|
||||
"2024-06-22" => 0,
|
||||
"2024-06-23" => 0,
|
||||
"2024-06-24" => 0,
|
||||
"2024-06-25" => 0,
|
||||
"2024-06-26" => 0,
|
||||
"2024-06-27" => 0,
|
||||
"2024-06-28" => 0,
|
||||
"2024-06-29" => 0,
|
||||
"2024-06-30" => 0
|
||||
]
|
||||
]
|
||||
WorkbenchLogic::month_order_count($dates_two,'本月订单数'),
|
||||
WorkbenchLogic::month_order_count($dates_two,'本月支付人数')
|
||||
]
|
||||
]
|
||||
];
|
||||
|
@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreProduct::where($this->searchWhere)
|
||||
->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code'])
|
||||
->field(['id', 'image', 'store_name', 'cate_id', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
|
@ -16,6 +16,7 @@ namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_visit\StoreVisit;
|
||||
use app\common\service\ConfigService;
|
||||
@ -52,27 +53,175 @@ class WorkbenchLogic extends BaseLogic
|
||||
*/
|
||||
public static function get_basic($where)
|
||||
{
|
||||
$browse=StoreVisit::where($where)->count();
|
||||
$user=0;
|
||||
$cart=0;
|
||||
$order=StoreOrder::where($where)->count();
|
||||
$pay=StoreOrder::where($where)->where('paid',1)->count();
|
||||
$payPrice=StoreOrder::where($where)->where('paid',1)->count('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;
|
||||
$browse = StoreVisit::where($where)->count();
|
||||
$user = 0;
|
||||
$cart = Cart::where($where)->where('is_fail', 0)->sum('cart_num');
|
||||
$order = StoreOrder::where($where)->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;
|
||||
return [
|
||||
'browse'=>['num'=>$browse,'title'=>'浏览量'],//浏览量
|
||||
'user'=>['num'=>$user,'title'=>'访客数'],//访客数
|
||||
'cart'=>['num'=>$cart,'title'=>'加购人数'],//加购人数
|
||||
'order'=>['num'=>$order,'title'=>'订单量'],//订单量
|
||||
'pay'=>['num'=>$pay,'title'=>'支付订单量'],//支付订单量
|
||||
'payPrice'=>['num'=>$payPrice,'title'=>'支付金额'],//支付金额
|
||||
'cost'=>['num'=>$cost,'title'=>'成本'],//成本
|
||||
'refundPrice'=>['num'=>$refundPrice,'title'=>'退款金额'],//退款金额
|
||||
'refund'=>['num'=>$refund,'title'=>'退款订单量'],//退款订单量
|
||||
'payPercent'=>['num'=>$payPercent,'title'=>'支付转化率'],//支付转化率
|
||||
'browse' => ['num' => $browse, 'title' => '浏览量'], //浏览量
|
||||
'user' => ['num' => $user, 'title' => '访客数'], //访客数
|
||||
'cart' => ['num' => $cart, 'title' => '加购人数'], //加购人数
|
||||
'order' => ['num' => $order, 'title' => '订单量'], //订单量
|
||||
'pay' => ['num' => $pay, 'title' => '支付订单量'], //支付订单量
|
||||
'payPrice' => ['num' => $payPrice, 'title' => '支付金额'], //支付金额
|
||||
'cost' => ['num' => $cost, 'title' => '成本'], //成本
|
||||
'refundPrice' => ['num' => $refundPrice, 'title' => '退款金额'], //退款金额
|
||||
'refund' => ['num' => $refund, 'title' => '退款订单量'], //退款订单量
|
||||
'payPercent' => ['num' => $payPercent, 'title' => '支付转化率'], //支付转化率
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品浏览量
|
||||
*/
|
||||
public static function store_visit_count($dates)
|
||||
{
|
||||
$data = [];
|
||||
foreach ($dates as $date) {
|
||||
$data[] = StoreVisit::whereDay('create_time', $date)->cache('store_visit_count_' . $date, 300)->sum('count');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品浏览量
|
||||
*/
|
||||
public static function store_visit_user($dates)
|
||||
{
|
||||
$data = [];
|
||||
foreach ($dates as $date) {
|
||||
$data[] = StoreVisit::whereDay('create_time', $date)->cache('store_visit_user_' . $date, 300)->count('uid');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 支付金额
|
||||
*/
|
||||
public static function payPrice($dates)
|
||||
{
|
||||
$data = [];
|
||||
foreach ($dates as $date) {
|
||||
$data[] = StoreOrder::whereDay('create_time', $date)->cache('payPrice_' . $date, 300)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
public static function refundPrice($dates)
|
||||
{
|
||||
$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');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当日订单金额
|
||||
*/
|
||||
public static function day_order_pay_price($where, $time)
|
||||
{
|
||||
$money = StoreOrder::whereDay('create_time', $time)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
|
||||
$data = [];
|
||||
foreach ($where as $date) {
|
||||
$data[] = StoreOrder::where('create_time','between', $date)->cache('day_order_pay_price_' . $date[0], 300)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
|
||||
}
|
||||
|
||||
return ['money' => $money, 'value' => $data];
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日订单数
|
||||
*/
|
||||
public static function day_order_count($where,$name)
|
||||
{
|
||||
$now_money = StoreOrder::whereDay('create_time')->where('paid', 1)->where('refund_status', 0)->count();
|
||||
$last_money = StoreOrder::whereDay('create_time', 'yesterday')->where('paid', 1)->where('refund_status', 0)->count();
|
||||
$data = [];
|
||||
foreach ($where as $date) {
|
||||
$data[] = StoreOrder::where('create_time','between', $date)->cache('day_order_count' . $date[0], 300)->where('paid', 1)->where('refund_status', 0)->count();
|
||||
}
|
||||
if ($now_money > $last_money) {
|
||||
if($last_money == 0){
|
||||
$rate = bcmul($now_money, '100');
|
||||
}else{
|
||||
$rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2);
|
||||
}
|
||||
} else {
|
||||
|
||||
$rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2);
|
||||
}
|
||||
return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data];
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日支付人数
|
||||
*/
|
||||
public static function day_order_user($where,$name)
|
||||
{
|
||||
$now_money = StoreOrder::whereDay('create_time')->where('paid', 1)->where('refund_status', 0)->count('uid');
|
||||
$last_money = StoreOrder::whereDay('create_time', 'yesterday')->where('paid', 1)->where('refund_status', 0)->count('uid');
|
||||
$data = [];
|
||||
foreach ($where as $date) {
|
||||
$data[] = StoreOrder::where('create_time','between', $date)->cache('day_order_count' . $date[0], 300)->where('paid', 1)->where('refund_status', 0)->count('uid');
|
||||
}
|
||||
if ($now_money > $last_money) {
|
||||
if($last_money == 0){
|
||||
$rate = bcmul($now_money, '100');
|
||||
}else{
|
||||
$rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2);
|
||||
}
|
||||
} else {
|
||||
|
||||
$rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2);
|
||||
}
|
||||
return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data];
|
||||
}
|
||||
/**
|
||||
* 本月订单数
|
||||
*/
|
||||
public static function month_order_count($name)
|
||||
{
|
||||
$now_money = StoreOrder::whereMonth('create_time')->where('paid', 1)->where('refund_status', 0)->count();
|
||||
$last_money = StoreOrder::whereMonth('create_time', 'last month')->where('paid', 1)->where('refund_status', 0)->count();
|
||||
$data = [];
|
||||
if ($now_money > $last_money) {
|
||||
if($last_money == 0){
|
||||
$rate = bcmul($now_money, '100');
|
||||
}else{
|
||||
$rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2);
|
||||
}
|
||||
} else {
|
||||
$rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2);
|
||||
}
|
||||
return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data];
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月支付人数
|
||||
*/
|
||||
public static function month_order_user($name)
|
||||
{
|
||||
$now_money = StoreOrder::whereMonth('create_time')->where('paid', 1)->where('refund_status', 0)->count('uid');
|
||||
$last_money = StoreOrder::whereMonth('create_time','last month')->where('paid', 1)->where('refund_status', 0)->count('uid');
|
||||
$data = [];
|
||||
if ($now_money > $last_money) {
|
||||
if($last_money == 0){
|
||||
$rate = bcmul($now_money, '100');
|
||||
}else{
|
||||
$rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2);
|
||||
}
|
||||
} else {
|
||||
|
||||
$rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2);
|
||||
}
|
||||
return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data];
|
||||
}
|
||||
}
|
||||
|
@ -42,25 +42,28 @@ class StoreProductLogic extends BaseLogic
|
||||
'cate_id' => $params['cate_id'],
|
||||
'unit' => $params['unit'],
|
||||
'stock' => $params['stock'],
|
||||
'price' => $params['price'],
|
||||
'vip_price' => $params['vip_price'],
|
||||
'cost' => $params['cost'],
|
||||
'purchase' => $params['purchase'],
|
||||
'rose' => $params['rose'],
|
||||
'is_return' => $params['is_return'],
|
||||
];
|
||||
if ($params['rose'] > 0) {
|
||||
$rose_price = bcmul($params['cost'], $params['rose'], 2);
|
||||
$data['price'] = bcadd($params['cost'], $rose_price, 2);
|
||||
} else {
|
||||
$data['price'] = 0;
|
||||
}
|
||||
// if ($params['rose'] > 0) {
|
||||
// $rose_price = bcmul($params['cost'], $params['rose'], 2);
|
||||
// $data['price'] = bcadd($params['cost'], $rose_price, 2);
|
||||
// } else {
|
||||
// $data['price'] = 0;
|
||||
// }
|
||||
$res = StoreProduct::create($data);
|
||||
StoreProductAttrValue::create([
|
||||
"bar_code" => $params["bar_code"] ?? '',
|
||||
"image" => $params["image"] ?? '',
|
||||
"price" => $params['price'],
|
||||
'vip_price' => $params['vip_price'],
|
||||
"cost" => $params['cost'],
|
||||
"purchase" => $params['purchase'],
|
||||
"unit" => $params["unit"],
|
||||
"price" => $data['price'],
|
||||
"stock" => $params['stock'],
|
||||
"product_id" => $res['id'],
|
||||
"unique" => setUnique($res['id'], '', 0),
|
||||
@ -113,16 +116,16 @@ class StoreProductLogic extends BaseLogic
|
||||
'purchase' => $params['purchase'],
|
||||
'rose' => $params['rose'],
|
||||
'is_return' => $params['is_return'],
|
||||
'price' => $params['price'],
|
||||
'vip_price' => $params['vip_price'],
|
||||
'cost' => $params['cost'],
|
||||
|
||||
];
|
||||
if ($params['rose'] > 0) {
|
||||
$rose_price = bcmul($params['cost'], bcdiv($params['rose'], 100, 2), 2);
|
||||
$data['price'] = bcadd($params['cost'], $rose_price, 2);
|
||||
} else {
|
||||
$data['price'] = 0;
|
||||
}
|
||||
StoreProduct::where('id', $params['id'])->update($data);
|
||||
|
||||
StoreBranchProduct::where('product_id', $params['id'])->update([
|
||||
'price' => $params['price'], 'vip_price' => $params['vip_price'],
|
||||
'cost' => $params['cost']
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -182,21 +185,21 @@ class StoreProductLogic extends BaseLogic
|
||||
$two = StoreCategory::where('id', $one['pid'])->find();
|
||||
if ($two) {
|
||||
if ($two['pid'] != 0) {
|
||||
self::cate_update($cate_id,$two['id'],0,3);
|
||||
self::cate_update($two['id'],$two['pid'],0,2);
|
||||
self::cate_update($two['pid'],0,0,1);
|
||||
self::cate_update($cate_id, $two['id'], 0, 3);
|
||||
self::cate_update($two['id'], $two['pid'], 0, 2);
|
||||
self::cate_update($two['pid'], 0, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function cate_update($cate_id = 0,$pid=0, $product_id = 0, $level = 1)
|
||||
public static function cate_update($cate_id = 0, $pid = 0, $product_id = 0, $level = 1)
|
||||
{
|
||||
$find = Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id, 'level' => $level])->find();
|
||||
if ($find) {
|
||||
Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update();
|
||||
} else {
|
||||
Db::name('store_product_cate')->insert(['pid'=>$pid,'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]);
|
||||
Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use Webman\RedisQueue\Redis;
|
||||
use hg\apidoc\annotation as ApiDoc;
|
||||
@ -141,7 +142,8 @@ class OrderController extends BaseApiController
|
||||
// $pay_type = (int)$this->request->post('pay_type');
|
||||
// $auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||
$params = $this->request->post();
|
||||
$res = OrderLogic::cartIdByOrderInfo($cartId, $addressId, null, $params);
|
||||
$user=User::where('id',$this->userId)->find();
|
||||
$res = OrderLogic::cartIdByOrderInfo($cartId, $addressId, $user, $params);
|
||||
if ($res == false) {
|
||||
$msg = OrderLogic::getError();
|
||||
if ($msg == '购物车为空') {
|
||||
@ -180,14 +182,9 @@ class OrderController extends BaseApiController
|
||||
return $this->fail('购物车商品不能超过100个');
|
||||
}
|
||||
|
||||
// if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) {
|
||||
// if (empty($this->request->userInfo['merchant'])) {
|
||||
// return $this->fail('请先绑定商户');
|
||||
// }
|
||||
// $mer_id = $this->request->userInfo['merchant']['mer_id'];
|
||||
// $params['mer_id'] = $mer_id;
|
||||
// }
|
||||
$order = OrderLogic::createOrder($cartId, $addressId, null, $params);
|
||||
$user=User::where('id',$this->userId)->find();
|
||||
|
||||
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
|
||||
if ($order != false) {
|
||||
switch ($pay_type) {
|
||||
case PayEnum::BALANCE_PAY:
|
||||
@ -367,7 +364,8 @@ class OrderController extends BaseApiController
|
||||
'id' => $order_id,
|
||||
'uid' => $this->userId,
|
||||
];
|
||||
$order = OrderLogic::detail($where);
|
||||
$url = 'https://'.$this->request->host(true);
|
||||
$order = OrderLogic::detail($where,$url);
|
||||
if ($order) {
|
||||
return $this->data($order);
|
||||
} else {
|
||||
|
@ -4,6 +4,7 @@ namespace app\api\controller\store;
|
||||
|
||||
use app\api\lists\store\SystemStoreLists;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\logic\store\StoreLogic;
|
||||
use app\common\service\pay\PayService;
|
||||
use Webman\Config;
|
||||
use hg\apidoc\annotation as ApiDoc;
|
||||
@ -11,11 +12,26 @@ use hg\apidoc\annotation as ApiDoc;
|
||||
|
||||
class StoreController extends BaseApiController
|
||||
{
|
||||
|
||||
public $notNeedLogin = ['detail'];
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SystemStoreLists());
|
||||
}
|
||||
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$store_id = (int)$this->request->get('store_id');
|
||||
$where = [
|
||||
'id' => $store_id
|
||||
];
|
||||
$info = StoreLogic::search($where);
|
||||
if ($info) {
|
||||
return $this->data($info);
|
||||
} else {
|
||||
return $this->fail('店铺不存在');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
|
||||
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select()
|
||||
->each(function ($v) use ($item) {
|
||||
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->find();
|
||||
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find();
|
||||
$v['store_name'] = $find['store_name'];
|
||||
$v['image'] = $find['image'];
|
||||
$v['price'] = $find['price'];
|
||||
@ -67,6 +67,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
if ($item['pay_time']) {
|
||||
$item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
|
||||
}
|
||||
if($item['verify_img']){
|
||||
$item['verify_img'] = 'https://'.$this->request->host(true).$item['verify_img'];
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
|
||||
|
@ -30,11 +30,11 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
$name=$this->request->get('name','');
|
||||
$name=$this->request->get('store_name','');
|
||||
// $where['%pipe_like%'] =['name'=>'store_name|bar_code'];
|
||||
if($name){
|
||||
if(preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){
|
||||
$where['%like%']=['store_name'];
|
||||
$where['%like%']=['store_name'=>'store_name'];
|
||||
}else{
|
||||
$where['=']=['bar_code','cate_id'];
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\model\user\UserShip;
|
||||
use Picqer\Barcode\BarcodeGeneratorJPG;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
use support\exception\BusinessException;
|
||||
use support\Log;
|
||||
use taoser\exception\ValidateException;
|
||||
@ -65,11 +67,10 @@ class OrderLogic extends BaseLogic
|
||||
self::$cost = 0; //成本
|
||||
self::$profit = 0; //利润
|
||||
self::$activity_price = 0; //活动减少
|
||||
|
||||
/** 计算价格 */
|
||||
$check = DictType::where('type', 'activities')->find();
|
||||
|
||||
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,cost,product_id')->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,product_id')->find();
|
||||
if (!$find) {
|
||||
continue;
|
||||
}
|
||||
@ -78,16 +79,16 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['price'] = $find['price'];
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
if (isset($check) && $check['status'] == 1) {
|
||||
//零售价*折扣率
|
||||
$activity_price = bcmul($find['price'], 0.9, 2);
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $activity_price, 2),$v['cart_num'], 2);
|
||||
if ($user && $user['user_ship'] >= 1) {
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
$find['price'] = $activity_price;
|
||||
$onePrice = bcsub($find['vip_price'], $find['cost'], 2);
|
||||
|
||||
}else{
|
||||
$onePrice = bcsub($find['price'], $find['cost'], 2);
|
||||
}
|
||||
//利润
|
||||
$onePrice = bcsub($find['price'], $find['cost'], 2);
|
||||
$cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额
|
||||
@ -95,14 +96,11 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['old_cart_id'] = $v['id'];
|
||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
||||
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
|
||||
|
||||
$cartInfo = $cart_select[$k];
|
||||
$cartInfo['name'] = $find['store_name'];
|
||||
$cartInfo['image'] = $find['image'];
|
||||
//计算好vip价格
|
||||
// $vipPrice = self::dealVip($find['price']);
|
||||
// if ($vipPrice) {
|
||||
// $cartInfo['price'] = $vipPrice;
|
||||
// }
|
||||
|
||||
$cartInfo['vip_price'] = 0; //$cart_select[$k]['total'] - $vipPrice ?? 0;
|
||||
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
||||
$cart_select[$k]['branch_product_id'] = $find['branch_product_id'];
|
||||
@ -116,47 +114,8 @@ class OrderLogic extends BaseLogic
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['cost'], 2);
|
||||
self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
|
||||
}
|
||||
//TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级
|
||||
$pay_price = self::$pay_price;
|
||||
// $check = StoreOrder::where('uid',\request()->userId)->count();//首单逻辑
|
||||
$pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
||||
$vipPrice = 0;
|
||||
// if (isset($check) && $check['status'] == 1) {
|
||||
// $discountRate = '0.99';//首单逻辑
|
||||
// $pay_price 是价格
|
||||
// $discountRate = $check['remark'];//折扣
|
||||
// $discountRate = bcdiv($discountRate, '10', 2);
|
||||
// $pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
|
||||
// } else {
|
||||
/* $userVip = User::where('id', \request()->userId)->value('user_ship');
|
||||
if ($userVip) {
|
||||
switch ($userVip) {
|
||||
case UserShipEnum::VIP1:
|
||||
$discountRate = UserShip::where('id', UserShipEnum::VIP1)->value('discount');
|
||||
break;
|
||||
case UserShipEnum::VIP2:
|
||||
$discountRate = UserShip::where('id', UserShipEnum::VIP2)->value('discount');
|
||||
break;
|
||||
case UserShipEnum::VIP3:
|
||||
$discountRate = UserShip::where('id', UserShipEnum::VIP3)->value('discount');
|
||||
break;
|
||||
case UserShipEnum::VIP4:
|
||||
$discountRate = UserShip::where('id', UserShipEnum::VIP4)->value('discount');
|
||||
break;
|
||||
case UserShipEnum::VIP5:
|
||||
$discountRate = UserShip::where('id', UserShipEnum::VIP5)->value('discount');
|
||||
break;
|
||||
default:
|
||||
$discountRate = 1;
|
||||
}
|
||||
$discountRate = bcdiv($discountRate, '100', 2);
|
||||
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
|
||||
}*/
|
||||
// }
|
||||
// if (!empty(self::$total) && !empty($pay_price)) {
|
||||
// bcscale(2);
|
||||
// $vipPrice = bcsub(self::$total, $pay_price, 2);
|
||||
// }
|
||||
|
||||
//成本价 收益
|
||||
$order = [
|
||||
'create_time' => time(),
|
||||
@ -174,7 +133,7 @@ class OrderLogic extends BaseLogic
|
||||
'shipping_type' => $params['shipping_type'] ?? 2, //配送方式 1=快递 ,2=门店自提
|
||||
'activity' => '减免',
|
||||
'activity_price' => self::$activity_price,
|
||||
'activities' => $check['status'],
|
||||
'activities' => self::$activity_price>0?1:0,
|
||||
'deduction_price' => self::$activity_price
|
||||
|
||||
];
|
||||
@ -227,7 +186,13 @@ class OrderLogic extends BaseLogic
|
||||
if ($params['shipping_type'] == 2) {
|
||||
$_order['status'] = 1;
|
||||
}
|
||||
|
||||
//生成核销码
|
||||
$generator = new BarcodeGeneratorPNG();
|
||||
$barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128);
|
||||
$findPath = '/image/barcode/'.time().'.png';
|
||||
$savePath = 'public'.$findPath;
|
||||
file_put_contents($savePath, $barcode);
|
||||
$_order['verify_img'] = $findPath;
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = StoreOrder::create($_order);
|
||||
@ -238,12 +203,15 @@ class OrderLogic extends BaseLogic
|
||||
$goods_list[$k]['uid'] = request()->userId;
|
||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||
$stock = StoreBranchProduct::where('id',$v['branch_product_id'])->value('stock');
|
||||
$StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->find();
|
||||
$updateData[] = [
|
||||
'id' => $v['branch_product_id'],
|
||||
'stock' => $stock-$v['cart_num'],
|
||||
'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);
|
||||
@ -352,7 +320,7 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
|
||||
|
||||
public static function detail($params): array
|
||||
public static function detail($params,$url=''): array
|
||||
{
|
||||
$find = StoreOrder::where($params)->findOrEmpty()->toArray();
|
||||
if ($find) {
|
||||
@ -370,6 +338,10 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
$store = SystemStore::where('id', $find['store_id'])->field('id,name,phone,address,detailed_address')->find();
|
||||
$find['store_info'] = $store;
|
||||
|
||||
if($find['verify_img']){
|
||||
$find['verify_img'] = $url.$find['verify_img'];
|
||||
}
|
||||
}
|
||||
return $find;
|
||||
}
|
||||
|
27
app/api/logic/store/StoreLogic.php
Normal file
27
app/api/logic/store/StoreLogic.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic\store;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use think\facade\Db;
|
||||
|
||||
class StoreLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
public static function search($param)
|
||||
{
|
||||
return SystemStore::where($param)
|
||||
->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show',
|
||||
'day_time', 'is_store', 'latitude', 'longitude', 'day_start', 'day_end', 'is_store'
|
||||
, 'is_send'
|
||||
])
|
||||
->find()
|
||||
->toArray();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -85,6 +85,8 @@ class OrderEnum
|
||||
const PAY = 1;
|
||||
const BACK = 0;
|
||||
|
||||
/**小程序下单**/
|
||||
const ONLINE = [1,2];
|
||||
/**
|
||||
* 账户类型
|
||||
* @USER 用户
|
||||
|
@ -125,9 +125,9 @@ class PayNotifyLogic extends BaseLogic
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
||||
} else {
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||
Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
||||
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
|
||||
}
|
||||
Redis::send('push-platform-print', ['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);
|
||||
}
|
||||
@ -206,6 +206,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
$cashFlowLogic = new CashFlowLogic();
|
||||
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
||||
Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,8 +242,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
||||
} else {
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||
Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
||||
}
|
||||
Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,8 @@ class StoreOrderLogic extends BaseLogic
|
||||
self::$activity_price = 0; //活动减少
|
||||
|
||||
/** 计算价格 */
|
||||
$check = DictType::where('type', 'activities')->find();
|
||||
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,cost,product_id')->find();
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,cost,product_id')->find();
|
||||
if (!$find) {
|
||||
continue;
|
||||
}
|
||||
@ -57,17 +56,9 @@ class StoreOrderLogic extends BaseLogic
|
||||
$cart_select[$k]['price'] = $find['price'];
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
if (isset($check) && $check['status'] == 1) {
|
||||
//零售价*折扣率
|
||||
$activity_price = bcmul($find['price'], 0.9, 2);
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $activity_price, 2),$v['cart_num'], 2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
$find['price'] = $activity_price;
|
||||
}
|
||||
|
||||
//利润
|
||||
$onePrice = bcsub($find['price'], $find['cost'], 2);
|
||||
$cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润
|
||||
$cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额
|
||||
$cart_select[$k]['product_id'] = $find['product_id'];
|
||||
@ -112,10 +103,10 @@ class StoreOrderLogic extends BaseLogic
|
||||
'reservation_time' => $params['reservation_time'] ?? null,
|
||||
'cart_id' => implode(',', $cartId),
|
||||
'store_id' => $params['store_id'] ?? 0,
|
||||
'shipping_type' => $params['shipping_type'] ?? 2,//配送方式 1=快递 ,2=门店自提
|
||||
'shipping_type' =>3,//配送方式 1=快递 ,2=门店自提
|
||||
'activity' =>'减免',
|
||||
'activity_price' =>self::$activity_price,
|
||||
'activities'=>$check['status'],
|
||||
'activities' => self::$activity_price>0?1:0,
|
||||
'default_delivery'=>1,
|
||||
'original_price'=>self::$total_price,
|
||||
'deduction_price' => self::$activity_price
|
||||
@ -202,6 +193,33 @@ class StoreOrderLogic extends BaseLogic
|
||||
return $order->toArray();
|
||||
}
|
||||
|
||||
//核销列表
|
||||
public function writeList($params)
|
||||
{
|
||||
$pageNo = $params['page_no'];
|
||||
$pageSize = $params['page_size'];
|
||||
unset($params['page_no'],$params['page_size']);
|
||||
$params['paid'] = YesNoEnum::YES;
|
||||
$params['is_writeoff'] = YesNoEnum::YES;
|
||||
$order = StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])->where($params)->whereIn('shipping_type',OrderEnum::ONLINE)
|
||||
->page($pageNo, $pageSize)
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($order as &$value){
|
||||
$value['pay_time'] = $value['pay_time'] > 0 ? date('Y-m-d H:i:s', $value['pay_time']) : '';
|
||||
$value['status_name'] = OrderEnum::getOrderType($value['status']) ?? '';
|
||||
$value['refund_status_name'] = OrderEnum::refundStatus($value['refund_status']) ?? '';
|
||||
$value['refund_type_name'] = OrderEnum::refundType($value['refund_type']) ?? '';
|
||||
$value['pay_type_name'] =PayEnum::getPaySceneDesc($value['pay_type']) ?? '';
|
||||
}
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 订单统计
|
||||
* @param $storeId
|
||||
|
@ -45,8 +45,9 @@ class StoreStorageSend implements Consumer
|
||||
'bar_code' => $find['bar_code'],
|
||||
'cate_id' => $find['cate_id'],
|
||||
'price' => $find['price'],
|
||||
'unit' => $find['unit'],
|
||||
'cost' => $find['cost'],
|
||||
'vip_price' => $find['vip_price'],
|
||||
'unit' => $find['unit'],
|
||||
'store_id' => $store_id,
|
||||
'sales' => 0,
|
||||
'stock' => 0,
|
||||
|
@ -251,4 +251,42 @@ class StoreOrderController extends BaseAdminController
|
||||
}
|
||||
return $this->fail('核销失败' . OrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
#[
|
||||
ApiDoc\Title('订单已核销列表'),
|
||||
ApiDoc\url('/store/store_order/storeOrder/writeoff_list'),
|
||||
ApiDoc\Method('POST'),
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Author('中国队长'),
|
||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||
ApiDoc\Query(name: 'page_no', type: 'int', require: false, desc: '页数 默认1'),
|
||||
ApiDoc\Query(name: 'page_size', type: 'int', require: false, desc: '每页条数 默认15'),
|
||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
]
|
||||
public function writeoff_list(StoreOrderLogic $orderLogic)
|
||||
{
|
||||
$page_no = (int)$this->request->post('page_no', 1);
|
||||
$page_size = (int)$this->request->post('page_size', 15);
|
||||
$params = $this->request->post();
|
||||
$params['page_no'] = $page_no;
|
||||
$params['page_size'] = $page_size;
|
||||
if (empty($page_no) || empty($page_size)) {
|
||||
$params['page_no'] = 1;
|
||||
$params['page_size'] = 15;
|
||||
}
|
||||
$params['store_id'] =$this->request->adminInfo['store_id'];
|
||||
$result = $orderLogic->writeList($params);
|
||||
|
||||
$data = [
|
||||
'lists' => $result,
|
||||
'count' => count($result),
|
||||
'page_no' => $params['page_no'],
|
||||
'page_size' =>$params['page_size'],
|
||||
];
|
||||
return $this->success('ok',$data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user