Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
This commit is contained in:
commit
9255bda969
@ -29,6 +29,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
return [
|
||||
'=' => ['order_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -47,17 +48,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])->where($this->searchWhere)
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
||||
}
|
||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
||||
})
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['status']), function ($query) {
|
||||
if ($this->params['status'] == -1) {
|
||||
@ -97,17 +89,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function count(): int
|
||||
{
|
||||
return StoreOrder::where($this->searchWhere)
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
||||
}
|
||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
||||
})
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['status']), function ($query) {
|
||||
if ($this->params['status'] == -1) {
|
||||
|
@ -44,6 +44,16 @@ class PayController extends BaseApiController
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if ($result && $result->event_type == 'REFUND.SUCCESS') {
|
||||
$ciphertext = $result->resource['ciphertext'];
|
||||
if ($ciphertext['refund_status'] === 'SUCCESS') {
|
||||
//处理订单 -1判断是退的一单还是拆分的订单
|
||||
PayNotifyLogic::handle('refund', $ciphertext['out_trade_no'], $ciphertext);
|
||||
$app->wechat->success();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,7 @@ class OrderLogic extends BaseLogic
|
||||
'vip_price'=>$vipPrice,
|
||||
'total_num' => count($cart_select),//总数
|
||||
'pay_type' => $params['pay_type'] ?? 0,
|
||||
'reservation_time' => $params['reservation_time'] ?? '',
|
||||
'cart_id' => implode(',', $cartId),
|
||||
'store_id' => $params['store_id'] ?? 0,
|
||||
'shipping_type' => $params['shipping_type'] ?? 1//配送方式 1=快递 ,2=门店自提
|
||||
|
@ -101,6 +101,9 @@ class OrderEnum
|
||||
* 订单状态
|
||||
* @CANCEL_ORDER 取消售后
|
||||
*/
|
||||
const REFUND_GOODS = -2;
|
||||
const REFUND_PAY = 4;
|
||||
|
||||
const CANCEL_ORDER = 5;
|
||||
|
||||
//退款状态
|
||||
|
@ -105,6 +105,9 @@ abstract class BaseDataLists implements ListsInterface
|
||||
$endTime = $this->request->get('end_time');
|
||||
if($endTime){
|
||||
$this->endTime = strtotime($endTime);
|
||||
if ($startTime == $endTime) {
|
||||
$this->endTime = strtotime($endTime) + 86399;
|
||||
}
|
||||
}
|
||||
$this->start = $this->request->get('start');
|
||||
$this->end = $this->request->get('end');
|
||||
|
@ -14,6 +14,7 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -21,18 +22,10 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
{
|
||||
$this->params['type'] = !empty($this->params['type']) ? $this->params['type'] : 1;
|
||||
return StoreFinanceFlow::with(['user', 'staff'])
|
||||
->where($this->searchWhere)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
||||
}
|
||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
||||
})
|
||||
->when(!empty($this->params['type']), function (Query $query) {
|
||||
$income = 1;
|
||||
$expense = 0;
|
||||
@ -70,18 +63,10 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
public function count(): int
|
||||
{
|
||||
return StoreFinanceFlow::where('1=1')
|
||||
->where($this->searchWhere)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
||||
}
|
||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
||||
})
|
||||
->when(!empty($this->params['type']), function (Query $query) {
|
||||
$income = 1;
|
||||
$expense = 0;
|
||||
|
@ -21,6 +21,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
{
|
||||
return [
|
||||
'=' => ['order_id', 'refund_type'],
|
||||
'between_time' => 'refund_reason_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -42,16 +43,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
->where($this->searchWhere)
|
||||
->where('refund_status', '>', 0)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('refund_reason_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
||||
}
|
||||
$query->whereTime('refund_reason_time', '<=', $this->params['end_time']);
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'refund_type', 'refund_reason_wap', 'refund_reason_time', 'refund_reason_wap_explain', 'refund_reason_wap_img', 'refund_reason'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
@ -77,16 +69,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
return StoreOrder::where($this->searchWhere)
|
||||
->where('refund_status', '>', 0)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('refund_reason_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
||||
}
|
||||
$query->whereTime('refund_reason_time', '<=', $this->params['end_time']);
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
@ -19,8 +19,15 @@ class PayNotifyLogLogic extends BaseLogic
|
||||
$model->pay_type = $payType;
|
||||
$model->order_sn = $data['out_trade_no'];
|
||||
$model->type = $type;
|
||||
$model->amount = $payType == 'wechat_common' ? $data['amount']['payer_total'] : $data['buyer_pay_amount'];
|
||||
$model->out_trade_no = $payType == 'wechat_common' ? $data['transaction_id'] : $data['trade_no'];
|
||||
if($type == PayNotifyLog::TYPE_REFUND){
|
||||
$model->amount = $data['amount']['refund'];
|
||||
$model->out_trade_no = $data['refund_id'];
|
||||
}else{
|
||||
$model->amount = $payType == 'wechat_common' ? $data['amount']['payer_total'] : $data['buyer_pay_amount'];
|
||||
$model->out_trade_no = $payType == 'wechat_common' ? $data['transaction_id'] : $data['trade_no'];
|
||||
|
||||
}
|
||||
|
||||
$model->transaction_id = $data['transaction_id'];
|
||||
$model->attach = $data['attach'] ?? '';
|
||||
if (isset($data['pay_time'])) {
|
||||
|
@ -6,6 +6,7 @@ use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\user\UserShipEnum;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\finance\PayNotifyLog;
|
||||
use app\common\model\pay\PayNotify;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
@ -31,7 +32,12 @@ class PayNotifyLogic extends BaseLogic
|
||||
try {
|
||||
if ($action != 'cash_pay' && $action != 'balancePay') {
|
||||
$payNotifyLogLogic = new PayNotifyLogLogic();
|
||||
$payNotifyLogLogic->insert($action, $extra);
|
||||
if($action == 'refund'){
|
||||
$payNotifyLogLogic->insert($action, $extra,PayNotifyLog::TYPE_REFUND);
|
||||
}else{
|
||||
$payNotifyLogLogic->insert($action, $extra);
|
||||
}
|
||||
|
||||
}
|
||||
self::$action($orderSn, $extra);
|
||||
Db::commit();
|
||||
@ -120,6 +126,23 @@ class PayNotifyLogic extends BaseLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
//退款
|
||||
public static function refund($orderSn, $extra = [])
|
||||
{
|
||||
//更新状态
|
||||
$order = StoreOrder::where('order_id',$orderSn)->findOrEmpty();
|
||||
// if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
|
||||
// return true;
|
||||
// }
|
||||
// $order->status = OrderEnum::REFUND_PAY;
|
||||
// $order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
|
||||
// $order->refund_price = bcdiv($extra['amount']['refund'], 100, 2);
|
||||
// $order->refund_reason_time = time();
|
||||
// $order->refund_num += 1;
|
||||
// $order->save();
|
||||
|
||||
// self::afterPay($order,$extra['transaction_id']);
|
||||
}
|
||||
|
||||
public static function recharge($orderSn, $extra = [])
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ namespace app\store\logic;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\store_order\StoreOrderLogic;
|
||||
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
@ -30,13 +31,7 @@ use app\common\service\FileService;
|
||||
*/
|
||||
class WorkbenchLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 工作套
|
||||
* @param $adminInfo
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:58
|
||||
*/
|
||||
|
||||
public static function index($params)
|
||||
{
|
||||
$data = [];
|
||||
@ -44,15 +39,18 @@ class WorkbenchLogic extends BaseLogic
|
||||
$endTime = $params['end_time'];
|
||||
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
|
||||
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
||||
if ($dateDiff->days > 366) {
|
||||
throw new \Exception('时间范围不能超过一年');
|
||||
}
|
||||
$orderLogic = new StoreOrderLogic();
|
||||
//订单总金额
|
||||
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime);
|
||||
//余额支付总金额
|
||||
$data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['pay_type' => PayEnum::BALANCE_PAY]);
|
||||
//线下收银总金额
|
||||
$data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 3]);
|
||||
$data['delivery_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 1]);
|
||||
//现金收银总金额
|
||||
$data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price');
|
||||
//核销订单金额
|
||||
$data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 2]);
|
||||
//门店成交用户数
|
||||
$data['user_number'] = StoreOrder::where('store_id', $params['store_id'])
|
||||
->where('paid', 1)
|
||||
->whereBetweenTime('create_time', $startTime, $endTime)
|
||||
@ -77,7 +75,17 @@ class WorkbenchLogic extends BaseLogic
|
||||
} else {
|
||||
$group = 'MONTH(pay_time)';
|
||||
$i = 0;
|
||||
while ($i <= $dateDiff->m) {
|
||||
$month = 0;
|
||||
if ($dateDiff->y > 0) {
|
||||
$month = $dateDiff->y * 12;
|
||||
}
|
||||
if ($dateDiff->m > 0) {
|
||||
$month += $dateDiff->m;
|
||||
}
|
||||
if ($dateDiff->d > 0) {
|
||||
$month += 1;
|
||||
}
|
||||
while ($i < $month) {
|
||||
$timeRange[] = date('Y-m', strtotime("+$i months", strtotime($startTime)));
|
||||
$i++;
|
||||
}
|
||||
@ -122,6 +130,17 @@ class WorkbenchLogic extends BaseLogic
|
||||
'user_number' => array_values($userListTmp)
|
||||
]
|
||||
];
|
||||
$data['order_list'] = StoreOrder::with('user')->where('store_id', $params['store_id'])
|
||||
->where('paid', 1)
|
||||
->whereBetweenTime('create_time', $startTime, $endTime)
|
||||
->order('create_time', 'desc')
|
||||
->limit(10)
|
||||
->select()->toArray();
|
||||
$data['pay_type'] = [
|
||||
['name' => '线上收银订单', 'value' => bcsub($data['order_amount'], bcadd($data['verify_amount'], $data['cash_amount'], 2), 2)],
|
||||
['name' => '核销订单', 'value' => $data['verify_amount']],
|
||||
['name' => '现金收银订单', 'value' => $data['cash_amount']],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user