commit
9fc4095563
@ -178,7 +178,11 @@ class WorkbenchController extends BaseAdminController
|
|||||||
public function get_user_basic()
|
public function get_user_basic()
|
||||||
{
|
{
|
||||||
$date=$this->request->get('date','');
|
$date=$this->request->get('date','');
|
||||||
|
$store_id=$this->request->get('store_id');
|
||||||
$where['create_time'] = $this->getDay($date);
|
$where['create_time'] = $this->getDay($date);
|
||||||
|
if($store_id){
|
||||||
|
$where['store_id'] = $store_id;
|
||||||
|
}
|
||||||
$data=(new UserStatisticLogic())->getBasic($where);
|
$data=(new UserStatisticLogic())->getBasic($where);
|
||||||
return $this->data($data);
|
return $this->data($data);
|
||||||
}
|
}
|
||||||
@ -189,7 +193,11 @@ class WorkbenchController extends BaseAdminController
|
|||||||
public function get_user_trend()
|
public function get_user_trend()
|
||||||
{
|
{
|
||||||
$date=$this->request->get('date','');
|
$date=$this->request->get('date','');
|
||||||
|
$store_id=$this->request->get('store_id');
|
||||||
$where['create_time'] = $this->getDay($date);
|
$where['create_time'] = $this->getDay($date);
|
||||||
|
if($store_id){
|
||||||
|
$where['store_id'] = $store_id;
|
||||||
|
}
|
||||||
$data=(new UserStatisticLogic())->getTrend($where);
|
$data=(new UserStatisticLogic())->getTrend($where);
|
||||||
|
|
||||||
return $this->data($data);
|
return $this->data($data);
|
||||||
|
@ -45,7 +45,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return WarehouseProduct::where($this->searchWhere)
|
return WarehouseProduct::where($this->searchWhere)
|
||||||
->field(['id', 'admin_id','warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'total_price', 'manufacture','expiration_date','status','mark'])
|
->field(['id', 'admin_id','warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price','purchase','cost', 'total_price', 'manufacture','expiration_date','status','mark','create_time'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item){
|
->select()->each(function ($item){
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace app\admin\logic\statistic;
|
namespace app\admin\logic\statistic;
|
||||||
|
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
|
||||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\model\user_recharge\UserRecharge;
|
use app\common\model\user_recharge\UserRecharge;
|
||||||
@ -277,8 +278,10 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
$lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum);
|
$lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum);
|
||||||
$offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time");
|
$offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time");
|
||||||
$offlineChain = countRate($offlineMoney, $lastOfflineMoney);
|
$offlineChain = countRate($offlineMoney, $lastOfflineMoney);
|
||||||
|
$cash=$this->getStoreCashFinanceFlowMoney($where);
|
||||||
$topData[6] = [
|
$topData[6] = [
|
||||||
'title' => '现金收银金额',
|
'title' => '现金收银金额',
|
||||||
|
'cash_title' => $cash,
|
||||||
'desc' => '选定条件下,用户在线下现金支付的金额',
|
'desc' => '选定条件下,用户在线下现金支付的金额',
|
||||||
'total_money' => $offlineMoney,
|
'total_money' => $offlineMoney,
|
||||||
'rate' => $offlineChain,
|
'rate' => $offlineChain,
|
||||||
@ -433,6 +436,7 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
$data['series'][$k]['name'] = $v['title'];
|
$data['series'][$k]['name'] = $v['title'];
|
||||||
$data['series'][$k]['desc'] = $v['desc'];
|
$data['series'][$k]['desc'] = $v['desc'];
|
||||||
$data['series'][$k]['money'] = $v['total_money'];
|
$data['series'][$k]['money'] = $v['total_money'];
|
||||||
|
$data['series'][$k]['cash_title'] = $v['cash_title']??'';
|
||||||
$data['series'][$k]['type'] = $v['type'];
|
$data['series'][$k]['type'] = $v['type'];
|
||||||
$data['series'][$k]['rate'] = $v['rate'];
|
$data['series'][$k]['rate'] = $v['rate'];
|
||||||
$data['series'][$k]['value'] = array_values($v['value']);
|
$data['series'][$k]['value'] = array_values($v['value']);
|
||||||
@ -770,6 +774,19 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
return $totalMoney;
|
return $totalMoney;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 现金上缴统计
|
||||||
|
*/
|
||||||
|
public function getStoreCashFinanceFlowMoney(array $where,)
|
||||||
|
{
|
||||||
|
$receivable= StoreCashFinanceFlow::where('status',0)->whereBetweenTime('create_time', strtotime($where['create_time']['start_time']), strtotime($where['create_time']['end_time']))->sum('receivable');
|
||||||
|
if($receivable>0){
|
||||||
|
return '未上缴'.$receivable;
|
||||||
|
}else{
|
||||||
|
return '已上缴';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理Y坐标数据
|
* 处理Y坐标数据
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@ -26,7 +26,8 @@ class UserStatisticLogic extends BaseLogic
|
|||||||
$time = [strtotime($time[0]), strtotime($time[1])];
|
$time = [strtotime($time[0]), strtotime($time[1])];
|
||||||
|
|
||||||
if (count($time) != 2) throw new Exception('参数错误');
|
if (count($time) != 2) throw new Exception('参数错误');
|
||||||
$userVisit = new UserVisit();
|
unset($where['create_time']);
|
||||||
|
// $userVisit = new UserVisit();
|
||||||
/** @var UserServices $user */
|
/** @var UserServices $user */
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$order = new StoreOrder();
|
$order = new StoreOrder();
|
||||||
@ -36,19 +37,19 @@ class UserStatisticLogic extends BaseLogic
|
|||||||
// /** @var OtherOrderServices $otherOrder */
|
// /** @var OtherOrderServices $otherOrder */
|
||||||
// $otherOrder = app()->make(OtherOrderServices::class);
|
// $otherOrder = app()->make(OtherOrderServices::class);
|
||||||
|
|
||||||
$now['people'] = $userVisit->where('create_time', 'between', $time)->group('uid')->count(); //访客数
|
$now['now_money'] = $user->where($where)->sum('now_money'); //余额
|
||||||
$now['browse'] = $userVisit->where('create_time', 'between', $time)->sum('id'); //访问量
|
$now['purchase_funds'] = $user->where($where)->sum('purchase_funds'); //采购款
|
||||||
$now['newUser'] = $user->where('create_time', 'between', $time)->count(); //新增用户数
|
$now['newUser'] = $user->where($where)->where('create_time', 'between', $time)->count(); //新增用户数
|
||||||
$now['payPeople'] = $order->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数
|
$now['payPeople'] = $order->where($where)->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数
|
||||||
$now['payPercent'] = bcmul((string)($now['people'] > 0 ? bcdiv($now['payPeople'], $now['people'], 4) : 0), '100', 2); //访问-付款转化率
|
// $now['payPercent'] = bcmul((string)($now['people'] > 0 ? bcdiv($now['payPeople'], $now['people'], 4) : 0), '100', 2); //访问-付款转化率
|
||||||
$now['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数
|
// $now['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数
|
||||||
$now['rechargePeople'] = $user_recharge->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数
|
$now['rechargePeople'] = $user_recharge->where($where)->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数
|
||||||
$totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price');
|
// $totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price');
|
||||||
$now['payPrice'] = floatval($now['payPeople'] > 0 ? bcdiv($totalPayPrice, $now['payPeople'], 2) : 0); //客单价
|
// $now['payPrice'] = floatval($now['payPeople'] > 0 ? bcdiv($totalPayPrice, $now['payPeople'], 2) : 0); //客单价
|
||||||
$now['cumulativeUser'] = $user->count(); //累计用户数
|
$now['cumulativeUser'] = $user->where($where)->count(); //累计用户数
|
||||||
$now['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($time[1]), $where['channel_type']));//到截至日期有付费会员状态的会员数
|
// $now['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($time[1]), $where['channel_type']));//到截至日期有付费会员状态的会员数
|
||||||
$now['cumulativeRechargePeople'] = $user_recharge->where('paid', 1)->group('uid')->count(); //累计充值用户数
|
$now['cumulativeRechargePeople'] = $user_recharge->where($where)->where('paid', 1)->group('uid')->count(); //累计充值用户数
|
||||||
$now['cumulativePayPeople'] = $order->where('paid', 1)->group('uid')->count(); //累计成交用户数
|
$now['cumulativePayPeople'] = $order->where($where)->where('paid', 1)->group('uid')->count(); //累计成交用户数
|
||||||
|
|
||||||
|
|
||||||
$dayNum = ($time[1] - $time[0]) / 86400 + 1;
|
$dayNum = ($time[1] - $time[0]) / 86400 + 1;
|
||||||
@ -58,19 +59,19 @@ class UserStatisticLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
// $where['time'] = implode('-', $lastTime);
|
// $where['time'] = implode('-', $lastTime);
|
||||||
// $toEndtime = implode('-', [0, $lastTime[1]]);
|
// $toEndtime = implode('-', [0, $lastTime[1]]);
|
||||||
$last['people'] = $userVisit->where('create_time', 'between', $time)->group('uid')->count(); //访客数
|
$last['now_money'] =$now['now_money'];
|
||||||
$last['browse'] = $userVisit->where('create_time', 'between', $time)->sum('id'); //访问量
|
$last['purchase_funds'] = $now['purchase_funds'];
|
||||||
$last['newUser'] = $user->where('create_time', 'between', $time)->count(); //新增用户数
|
$last['newUser'] = $user->where($where)->where('create_time', 'between', $time)->count(); //新增用户数
|
||||||
$last['payPeople'] = $order->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数
|
$last['payPeople'] = $order->where($where)->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数
|
||||||
$last['payPercent'] = bcmul((string)($last['people'] > 0 ? bcdiv($last['payPeople'], $last['people'], 4) : 0), '100', 2); //访问-付款转化率
|
// $last['payPercent'] = bcmul((string)($last['people'] > 0 ? bcdiv($last['payPeople'], $last['people'], 4) : 0), '100', 2); //访问-付款转化率
|
||||||
$last['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数
|
// $last['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数
|
||||||
$last['rechargePeople'] = $user_recharge->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数
|
$last['rechargePeople'] = $user_recharge->where($where)->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数
|
||||||
$totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price');
|
// $totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price');
|
||||||
$last['payPrice'] = floatval($last['payPeople'] > 0 ? bcdiv($totalPayPrice, $last['payPeople'], 2) : 0); //客单价
|
// $last['payPrice'] = floatval($last['payPeople'] > 0 ? bcdiv($totalPayPrice, $last['payPeople'], 2) : 0); //客单价
|
||||||
$last['cumulativeUser'] = $user->count(); //累计用户数
|
$last['cumulativeUser'] = $user->where($where)->count(); //累计用户数
|
||||||
$last['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($lastTime[1]) + 86400, $where['channel_type']));//到截至日期有付费会员状态的会员数
|
// $last['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($lastTime[1]) + 86400, $where['channel_type']));//到截至日期有付费会员状态的会员数
|
||||||
$last['cumulativeRechargePeople'] = $user_recharge->where('paid', 1)->group('uid')->count(); //累计充值用户数
|
$last['cumulativeRechargePeople'] = $user_recharge->where($where)->where('paid', 1)->group('uid')->count(); //累计充值用户数
|
||||||
$last['cumulativePayPeople'] = $order->where('paid', 1)->group('uid')->count(); //累计成交用户数
|
$last['cumulativePayPeople'] = $order->where($where)->where('paid', 1)->group('uid')->count(); //累计成交用户数
|
||||||
|
|
||||||
//组合数据,计算环比
|
//组合数据,计算环比
|
||||||
$data = [];
|
$data = [];
|
||||||
@ -93,18 +94,18 @@ class UserStatisticLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
$time = explode('-', $where['create_time']);
|
$time = explode('-', $where['create_time']);
|
||||||
$time = [strtotime($time[0]), strtotime($time[1])];
|
$time = [strtotime($time[0]), strtotime($time[1])];
|
||||||
$channelType = ''; //$where['channel_type'];
|
unset($where['create_time']);
|
||||||
if (count($time) != 2) throw new Exception('参数错误');
|
if (count($time) != 2) throw new Exception('参数错误');
|
||||||
$dayCount = ($time[1] - $time[0]) / 86400 + 1;
|
$dayCount = ($time[1] - $time[0]) / 86400 + 1;
|
||||||
$data = [];
|
$data = [];
|
||||||
if ($dayCount == 1) {
|
if ($dayCount == 1) {
|
||||||
$data = $this->trend($time, $channelType, 0, $excel);
|
$data = $this->trend($time, $where, 0, $excel);
|
||||||
} elseif ($dayCount > 1 && $dayCount <= 31) {
|
} elseif ($dayCount > 1 && $dayCount <= 31) {
|
||||||
$data = $this->trend($time, $channelType, 1, $excel);
|
$data = $this->trend($time, $where, 1, $excel);
|
||||||
} elseif ($dayCount > 31 && $dayCount <= 92) {
|
} elseif ($dayCount > 31 && $dayCount <= 92) {
|
||||||
$data = $this->trend($time, $channelType, 3, $excel);
|
$data = $this->trend($time, $where, 3, $excel);
|
||||||
} elseif ($dayCount > 92) {
|
} elseif ($dayCount > 92) {
|
||||||
$data = $this->trend($time, $channelType, 30, $excel);
|
$data = $this->trend($time, $where, 30, $excel);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -117,19 +118,18 @@ class UserStatisticLogic extends BaseLogic
|
|||||||
* @param $excel
|
* @param $excel
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function trend($time, $channelType, $num, $excel)
|
public function trend($time, $where, $num, $excel)
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$userVisit = new UserVisit();
|
// $userVisit = new UserVisit();
|
||||||
$order = new StoreOrder();
|
$order = new StoreOrder();
|
||||||
$recharge = new UserRecharge();
|
$recharge = new UserRecharge();
|
||||||
|
|
||||||
$newPeople = $visitPeople = $paidPeople = $rechargePeople = $vipPeople = [];
|
$newPeople = $paidPeople = $rechargePeople = $vipPeople = [];
|
||||||
$newPeople['name'] = '新增用户数';
|
$newPeople['name'] = '新增用户';
|
||||||
$visitPeople['name'] = '访客数';
|
// $visitPeople['name'] = '访客数';
|
||||||
$paidPeople['name'] = '成交用户数';
|
$paidPeople['name'] = '成交用户';
|
||||||
$rechargePeople['name'] = '充值用户';
|
$vipPeople['name'] = '新增会员用户';
|
||||||
$vipPeople['name'] = '新增付费用户数';
|
|
||||||
if ($num == 0) {
|
if ($num == 0) {
|
||||||
$xAxis = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
|
$xAxis = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
|
||||||
$timeType = '%H';
|
$timeType = '%H';
|
||||||
@ -148,19 +148,17 @@ class UserStatisticLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$visitPeople = array_column($userVisit->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');
|
// $visitPeople = array_column($userVisit->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');
|
||||||
$newPeople = array_column($user->getTrendData($time, $channelType, $timeType), 'num', 'days');
|
$newPeople = array_column($user->getTrendData($time, [], $timeType), 'num', 'days');
|
||||||
$paidPeople = array_column($order->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');
|
$paidPeople = array_column($order->getTrendData($time, $where, $timeType, 'count(distinct(uid))'), 'num', 'days');
|
||||||
$rechargePeople = array_column($recharge->getTrendData(['paid'=>1],$time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');
|
$vipPeople = array_column($user->getTrendData($time, [], $timeType, 'vip_time'), 'days');
|
||||||
$vipPeople = array_column($recharge->getTrendData(['paid'=>1,'price'=>1000],$time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');
|
|
||||||
|
|
||||||
$data = $series = [];
|
$data = $series = [];
|
||||||
foreach ($xAxis as $item) {
|
foreach ($xAxis as $item) {
|
||||||
$data['新增用户数'][] = isset($newPeople[$item]) ? intval($newPeople[$item]) : 0;
|
$data['新增用户'][] = isset($newPeople[$item]) ? intval($newPeople[$item]) : 0;
|
||||||
$data['访客数'][] = isset($visitPeople[$item]) ? intval($visitPeople[$item]) : 0;
|
// $data['访客数'][] = isset($visitPeople[$item]) ? intval($visitPeople[$item]) : 0;
|
||||||
$data['成交用户数'][] = isset($paidPeople[$item]) ? intval($paidPeople[$item]) : 0;
|
$data['成交用户'][] = isset($paidPeople[$item]) ? intval($paidPeople[$item]) : 0;
|
||||||
$data['充值用户'][] = isset($rechargePeople[$item]) ? intval($rechargePeople[$item]) : 0;
|
$data['新增会员用户'][] = isset($vipPeople[$item]) ? intval($vipPeople[$item]) : 0;
|
||||||
$data['新增付费用户数'][] = isset($vipPeople[$item]) ? intval($vipPeople[$item]) : 0;
|
|
||||||
}
|
}
|
||||||
foreach ($data as $key => $item) {
|
foreach ($data as $key => $item) {
|
||||||
$series[] = ['name' => $key, 'value' => $item];
|
$series[] = ['name' => $key, 'value' => $item];
|
||||||
|
@ -5,6 +5,7 @@ namespace app\admin\logic\warehouse_product;
|
|||||||
|
|
||||||
use app\common\model\warehouse_product\WarehouseProduct;
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
@ -31,27 +32,29 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$data=[
|
$data = [
|
||||||
'warehouse_id' => $params['warehouse_id'],
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
'financial_pm' => $params['financial_pm'],
|
'financial_pm' => $params['financial_pm'],
|
||||||
'batch' => $params['batch'],
|
'batch' => 0,
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'price' => $params['price']??'',
|
'price' => $params['price'] ?? '',
|
||||||
'total_price' => $params['total_price']??'',
|
'purchase' => $params['purchase'] ?? '',
|
||||||
|
'cost' => $params['cost'] ?? '',
|
||||||
|
'total_price' => $params['total_price'] ?? '',
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
'code' => $params['code']??'',
|
'code' => $params['code'] ?? '',
|
||||||
'status' => $params['status']??0,
|
'status' => $params['status'] ?? 0,
|
||||||
'mark' => $params['mark']??'',
|
'mark' => $params['mark'] ?? '',
|
||||||
];
|
];
|
||||||
if(isset($params['manufacture']) &&$params['manufacture']!=''){
|
if (isset($params['manufacture']) && $params['manufacture'] != '') {
|
||||||
$data['manufacture']=strtotime($params['manufacture']);
|
$data['manufacture'] = strtotime($params['manufacture']);
|
||||||
}
|
}
|
||||||
if(isset($params['expiration_date']) &&$params['expiration_date']!=''){
|
if (isset($params['expiration_date']) && $params['expiration_date'] != '') {
|
||||||
$data['expiration_date']=strtotime($params['expiration_date']);
|
$data['expiration_date'] = strtotime($params['expiration_date']);
|
||||||
}
|
}
|
||||||
$res=WarehouseProduct::create($data);
|
$res = WarehouseProduct::create($data);
|
||||||
self::enter($res['id'],$params['financial_pm']);
|
self::enter($res['id'], $params['financial_pm']);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -73,29 +76,32 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$data=[
|
$data = [
|
||||||
'warehouse_id' => $params['warehouse_id'],
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
'financial_pm' => $params['financial_pm'],
|
'financial_pm' => $params['financial_pm'],
|
||||||
'batch' => $params['batch'],
|
'batch' => WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm']])->count(),
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'price' => $params['price'],
|
'price' => $params['price'],
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
'total_price' => $params['total_price'],
|
'total_price' => $params['total_price'],
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
|
'purchase' => $params['purchase'] ?? '',
|
||||||
|
'cost' => $params['cost'] ?? '',
|
||||||
];
|
];
|
||||||
if(isset($params['manufacture']) &&$params['manufacture']!=''){
|
if (isset($params['manufacture']) && $params['manufacture'] != '') {
|
||||||
$data['manufacture']=strtotime($params['manufacture']);
|
$data['manufacture'] = strtotime($params['manufacture']);
|
||||||
}
|
}
|
||||||
if(isset($params['expiration_date']) &&$params['expiration_date']!=''){
|
if (isset($params['expiration_date']) && $params['expiration_date'] != '') {
|
||||||
$data['expiration_date']=strtotime($params['expiration_date']);
|
$data['expiration_date'] = strtotime($params['expiration_date']);
|
||||||
}
|
}
|
||||||
$res=WarehouseProduct::where('id', $params['id'])->update($data);
|
$res = WarehouseProduct::where('id', $params['id'])->update($data);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $res;
|
return $res;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -107,40 +113,36 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
* @author admin
|
* @author admin
|
||||||
* @date 2024/07/31 16:55
|
* @date 2024/07/31 16:55
|
||||||
*/
|
*/
|
||||||
public static function enter($id,$financial_pm=0)
|
public static function enter($id, $financial_pm = 0)
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
$find=WarehouseProduct::where('id',$id)->find();
|
|
||||||
$find->status=1;
|
|
||||||
$find->save();
|
|
||||||
$storege=WarehouseProductStorege::where('warehouse_id',$find['warehouse_id'])->where('product_id',$find['product_id'])->find();
|
|
||||||
if($financial_pm==0){
|
|
||||||
StoreProduct::where('id',$find['product_id'])->dec('stock',$find['nums'])->update();
|
|
||||||
}else{
|
|
||||||
StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update();
|
|
||||||
}
|
|
||||||
if($storege){
|
|
||||||
if($financial_pm==0){
|
|
||||||
$storege->nums=bcsub($storege->nums,$find['nums']);
|
|
||||||
}else{
|
|
||||||
$storege->nums=bcadd($storege->nums,$find['nums']);
|
|
||||||
}
|
|
||||||
$storege->save();
|
|
||||||
|
|
||||||
}else{
|
$find = WarehouseProduct::where('id', $id)->find();
|
||||||
WarehouseProductStorege::create([
|
$find->status = 1;
|
||||||
'warehouse_id' => $find['warehouse_id'],
|
$find->batch = WarehouseProduct::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id'], 'financial_pm' => $financial_pm])->count();
|
||||||
'product_id' => $find['product_id'],
|
$find->save();
|
||||||
'nums' => $find['nums'],
|
|
||||||
]);
|
$storege = WarehouseProductStorege::where('warehouse_id', $find['warehouse_id'])->where('product_id', $find['product_id'])->find();
|
||||||
|
if ($financial_pm == 0) {
|
||||||
|
StoreProduct::where('id', $find['product_id'])->dec('stock', $find['nums'])->update();
|
||||||
|
} else {
|
||||||
|
StoreProduct::where('id', $find['product_id'])->inc('stock', $find['nums'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]);
|
||||||
|
StoreBranchProduct::where('product_id', $find['product_id'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($storege) {
|
||||||
|
if ($financial_pm == 0) {
|
||||||
|
$storege->nums = bcsub($storege->nums, $find['nums']);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$storege->nums = bcadd($storege->nums, $find['nums']);
|
||||||
}
|
}
|
||||||
Db::commit();
|
$storege->save();
|
||||||
return true;
|
} else {
|
||||||
} catch (\Exception $e) {
|
WarehouseProductStorege::create([
|
||||||
Db::rollback();
|
'warehouse_id' => $find['warehouse_id'],
|
||||||
self::setError($e->getMessage());
|
'product_id' => $find['product_id'],
|
||||||
return false;
|
'nums' => $find['nums'],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,11 +169,10 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
$data= WarehouseProduct::findOrEmpty($params['id'])->toArray();
|
$data = WarehouseProduct::findOrEmpty($params['id'])->toArray();
|
||||||
if($data){
|
if ($data) {
|
||||||
$data['manufacture']=date('Y-m-d',$data['manufacture']);
|
$data['manufacture'] = date('Y-m-d', $data['manufacture']);
|
||||||
$data['expiration_date']=date('Y-m-d',$data['expiration_date']);
|
$data['expiration_date'] = date('Y-m-d', $data['expiration_date']);
|
||||||
|
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class WarehouseProductValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['warehouse_id','product_id','financial_pm','batch','nums','price','total_price']);
|
return $this->only(['warehouse_id','product_id','financial_pm','nums','price','total_price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class WarehouseProductValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id','warehouse_id','product_id','financial_pm','batch','nums','price','total_price']);
|
return $this->only(['id','warehouse_id','product_id','financial_pm','nums','price','total_price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,11 +78,9 @@ class StoreOrder extends BaseModel
|
|||||||
* @param $timeType
|
* @param $timeType
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getTrendData($time, $type, $timeType, $str)
|
public function getTrendData($time, $where, $timeType, $str)
|
||||||
{
|
{
|
||||||
return $this->when($type != '', function ($query) use ($type) {
|
return $this->where($where)->where('paid', 1)->where('refund_status', '=', 0)->where(function ($query) use ($time) {
|
||||||
$query->where('channel_type', $type);
|
|
||||||
})->where('paid', 1)->where('paid', '>=', 0)->where(function ($query) use ($time) {
|
|
||||||
if ($time[0] == $time[1]) {
|
if ($time[0] == $time[1]) {
|
||||||
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,17 +184,15 @@ class User extends BaseModel
|
|||||||
* @param $timeType
|
* @param $timeType
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getTrendData($time, $type, $timeType)
|
public function getTrendData($time, $where, $timeType,$create_time='create_time')
|
||||||
{
|
{
|
||||||
return $this->when($type != '', function ($query) use ($type) {
|
return $this->where($where)->where(function ($query) use ($time,$create_time) {
|
||||||
$query->where('user_type', $type);
|
|
||||||
})->where(function ($query) use ($time) {
|
|
||||||
if ($time[0] == $time[1]) {
|
if ($time[0] == $time[1]) {
|
||||||
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
$query->whereDay($create_time, date('Y-m-d',$time[0]));
|
||||||
} else {
|
} else {
|
||||||
$time[1] = $time[1] + 86400;
|
$time[1] = $time[1] + 86400;
|
||||||
$query->whereTime('create_time', 'between', $time);
|
$query->whereTime($create_time, 'between', $time);
|
||||||
}
|
}
|
||||||
})->field("FROM_UNIXTIME(create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray();
|
})->field("FROM_UNIXTIME($create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user