|
@@ -2,21 +2,30 @@
|
|
|
|
|
|
namespace app\admin\controller\order;
|
|
namespace app\admin\controller\order;
|
|
|
|
|
|
|
|
+use app\admin\service\coupon\CouponService;
|
|
use app\admin\service\member\MemberService;
|
|
use app\admin\service\member\MemberService;
|
|
use app\admin\service\order\OrderService;
|
|
use app\admin\service\order\OrderService;
|
|
use app\admin\validate\order\OrderValidate;
|
|
use app\admin\validate\order\OrderValidate;
|
|
use app\controller\Curd;
|
|
use app\controller\Curd;
|
|
use app\model\Appointment;
|
|
use app\model\Appointment;
|
|
|
|
+use app\model\ClientConfig;
|
|
|
|
+use app\model\Coupon;
|
|
use app\model\Goods;
|
|
use app\model\Goods;
|
|
use app\model\GoodsComponent;
|
|
use app\model\GoodsComponent;
|
|
use app\model\GoodsRunning;
|
|
use app\model\GoodsRunning;
|
|
use app\model\GoodsSku;
|
|
use app\model\GoodsSku;
|
|
use app\model\Member;
|
|
use app\model\Member;
|
|
use app\model\MemberAccount;
|
|
use app\model\MemberAccount;
|
|
|
|
+use app\model\MemberBenefit;
|
|
|
|
+use app\model\MemberRole;
|
|
use app\model\Order;
|
|
use app\model\Order;
|
|
|
|
+use app\model\OrderExpress;
|
|
|
|
+use app\model\OrderReturn;
|
|
use app\model\OrderSheet;
|
|
use app\model\OrderSheet;
|
|
use app\model\PayDetail;
|
|
use app\model\PayDetail;
|
|
|
|
+use app\model\Supplier;
|
|
use app\model\SysDept;
|
|
use app\model\SysDept;
|
|
|
|
+use app\model\SysUser;
|
|
use support\Db;
|
|
use support\Db;
|
|
use support\exception\BusinessException;
|
|
use support\exception\BusinessException;
|
|
use support\Redis;
|
|
use support\Redis;
|
|
@@ -24,7 +33,8 @@ use support\Request;
|
|
use support\Response;
|
|
use support\Response;
|
|
use Webman\Event\Event;
|
|
use Webman\Event\Event;
|
|
|
|
|
|
-class KangyangCityController extends Curd{
|
|
|
|
|
|
+class KangyangCityController extends Curd
|
|
|
|
+{
|
|
public function __construct()
|
|
public function __construct()
|
|
{
|
|
{
|
|
$this->model = new Order();
|
|
$this->model = new Order();
|
|
@@ -54,9 +64,9 @@ class KangyangCityController extends Curd{
|
|
// $where['order_id'] = '';
|
|
// $where['order_id'] = '';
|
|
$where['order_category'] = 'VIP';
|
|
$where['order_category'] = 'VIP';
|
|
// $goodsClassify = 'VIP';
|
|
// $goodsClassify = 'VIP';
|
|
- $goodsName = $request->get('goods_name','');
|
|
|
|
- if (!empty($goodsName) && empty($goodsClassify)){
|
|
|
|
- $goodsIds = Goods::where('goods_name','like','%'.$request->get('goods_name').'%')->pluck('goods_id')->toArray();
|
|
|
|
|
|
+ $goodsName = $request->get('goods_name', '');
|
|
|
|
+ if (!empty($goodsName) && empty($goodsClassify)) {
|
|
|
|
+ $goodsIds = Goods::where('goods_name', 'like', '%' . $request->get('goods_name') . '%')->pluck('goods_id')->toArray();
|
|
}
|
|
}
|
|
// else if(!empty($goodsClassify)){
|
|
// else if(!empty($goodsClassify)){
|
|
// if($goodsClassify == 'SERVICE'){
|
|
// if($goodsClassify == 'SERVICE'){
|
|
@@ -71,10 +81,10 @@ class KangyangCityController extends Curd{
|
|
|
|
|
|
// $goodsIds = $goodsModel->pluck('goods_id')->toArray();
|
|
// $goodsIds = $goodsModel->pluck('goods_id')->toArray();
|
|
// }
|
|
// }
|
|
- if(!empty($goodsIds)){
|
|
|
|
- $orderIds = OrderSheet::whereIn('join_sheet_goods_id',$goodsIds)->pluck('join_sheet_order_id')->toArray();
|
|
|
|
- if($orderIds){
|
|
|
|
- $where['order_id'] = ['in',implode(',',$orderIds)];
|
|
|
|
|
|
+ if (!empty($goodsIds)) {
|
|
|
|
+ $orderIds = OrderSheet::whereIn('join_sheet_goods_id', $goodsIds)->pluck('join_sheet_order_id')->toArray();
|
|
|
|
+ if ($orderIds) {
|
|
|
|
+ $where['order_id'] = ['in', implode(',', $orderIds)];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -86,7 +96,7 @@ class KangyangCityController extends Curd{
|
|
{
|
|
{
|
|
$model = $this->model->with([
|
|
$model = $this->model->with([
|
|
'sheets' => function ($query) {
|
|
'sheets' => function ($query) {
|
|
- $query->select('join_sheet_order_id', 'order_sheet_id', 'join_sheet_goods_id', 'order_sheet_num','order_sheet_price');
|
|
|
|
|
|
+ $query->select('join_sheet_order_id', 'order_sheet_id', 'join_sheet_goods_id', 'order_sheet_num', 'order_sheet_price');
|
|
},
|
|
},
|
|
'member' => function ($query) {
|
|
'member' => function ($query) {
|
|
$query->select('member_id', 'member_mobile');
|
|
$query->select('member_id', 'member_mobile');
|
|
@@ -104,8 +114,8 @@ class KangyangCityController extends Curd{
|
|
// 'express' => function ($query) {
|
|
// 'express' => function ($query) {
|
|
// $query->select('join_express_order_id', 'order_express_type');
|
|
// $query->select('join_express_order_id', 'order_express_type');
|
|
// }
|
|
// }
|
|
- ])->leftJoin('order_return','order_return.join_return_order_id','=','order.order_id')
|
|
|
|
- ->leftJoin('order_express','order_express.join_express_order_id','=','order.order_id');
|
|
|
|
|
|
+ ])->leftJoin('order_return', 'order_return.join_return_order_id', '=', 'order.order_id')
|
|
|
|
+ ->leftJoin('order_express', 'order_express.join_express_order_id', '=', 'order.order_id');
|
|
// ->leftJoin('order_sheet','join_sheet_order_id','=','order.order_id');
|
|
// ->leftJoin('order_sheet','join_sheet_order_id','=','order.order_id');
|
|
foreach ($where as $column => $value) {
|
|
foreach ($where as $column => $value) {
|
|
if (is_array($value)) {
|
|
if (is_array($value)) {
|
|
@@ -139,7 +149,7 @@ class KangyangCityController extends Curd{
|
|
if ($field) {
|
|
if ($field) {
|
|
$model = $model->orderBy($field, $order);
|
|
$model = $model->orderBy($field, $order);
|
|
}
|
|
}
|
|
- $model = $model->select('order.*','order_express.join_express_order_id','order_express.order_express_type','order_return.orders_return_id', 'order_return.join_return_order_id', 'order_return.order_return_status','order_return.order_return_apply_json','order_return.order_return_remark');
|
|
|
|
|
|
+ $model = $model->select('order.*', 'order_express.join_express_order_id', 'order_express.order_express_type', 'order_return.orders_return_id', 'order_return.join_return_order_id', 'order_return.order_return_status', 'order_return.order_return_apply_json', 'order_return.order_return_remark');
|
|
return $model;
|
|
return $model;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -150,29 +160,29 @@ class KangyangCityController extends Curd{
|
|
$item['sheet'] = $item['sheets'][0] ?? [];
|
|
$item['sheet'] = $item['sheets'][0] ?? [];
|
|
if (!empty($item['sheet'])) {
|
|
if (!empty($item['sheet'])) {
|
|
$goods = Goods::where('goods_id', $item['sheet']['join_sheet_goods_id'])->first();
|
|
$goods = Goods::where('goods_id', $item['sheet']['join_sheet_goods_id'])->first();
|
|
- if(count($item['sheets']) > 1 && $goods->goods_classify == 'MEALS'){
|
|
|
|
|
|
+ if (count($item['sheets']) > 1 && $goods->goods_classify == 'MEALS') {
|
|
$sheetDeng = ' 等餐品';
|
|
$sheetDeng = ' 等餐品';
|
|
}
|
|
}
|
|
- $item['sheet']['goods_name'] = ($goods && $goods->goods_name) ? $goods->goods_name.$sheetDeng : '';
|
|
|
|
|
|
+ $item['sheet']['goods_name'] = ($goods && $goods->goods_name) ? $goods->goods_name . $sheetDeng : '';
|
|
$item['sheet']['goods_classify'] = $goods->goods_classify ?? '';
|
|
$item['sheet']['goods_classify'] = $goods->goods_classify ?? '';
|
|
$item['sheet']['order_sheet_num'] = intval($item['sheet']['order_sheet_num']);
|
|
$item['sheet']['order_sheet_num'] = intval($item['sheet']['order_sheet_num']);
|
|
}
|
|
}
|
|
unset($item['sheets']);
|
|
unset($item['sheets']);
|
|
- if (isset($item['orders_return_id'])){
|
|
|
|
|
|
+ if (isset($item['orders_return_id'])) {
|
|
$item['return'] = [
|
|
$item['return'] = [
|
|
- 'orders_return_id'=>$item['orders_return_id'],
|
|
|
|
|
|
+ 'orders_return_id' => $item['orders_return_id'],
|
|
'join_return_order_id' => $item['join_return_order_id'],
|
|
'join_return_order_id' => $item['join_return_order_id'],
|
|
'order_return_status' => $item['order_return_status'],
|
|
'order_return_status' => $item['order_return_status'],
|
|
'order_return_apply_json' => $item['order_return_apply_json'],
|
|
'order_return_apply_json' => $item['order_return_apply_json'],
|
|
- 'order_return_remark'=>$item['order_return_remark']
|
|
|
|
|
|
+ 'order_return_remark' => $item['order_return_remark']
|
|
];
|
|
];
|
|
}
|
|
}
|
|
- if (isset($item['join_express_order_id'])){
|
|
|
|
|
|
+ if (isset($item['join_express_order_id'])) {
|
|
$item['express'] = [
|
|
$item['express'] = [
|
|
- 'join_express_order_id'=>$item['join_express_order_id'],
|
|
|
|
- 'order_express_type'=>$item['order_express_type']
|
|
|
|
|
|
+ 'join_express_order_id' => $item['join_express_order_id'],
|
|
|
|
+ 'order_express_type' => $item['order_express_type']
|
|
];
|
|
];
|
|
- unset($item['join_express_order_id'],$item['order_express_type']);
|
|
|
|
|
|
+ unset($item['join_express_order_id'], $item['order_express_type']);
|
|
}
|
|
}
|
|
// if (!empty($item['order_extend_json'])){
|
|
// if (!empty($item['order_extend_json'])){
|
|
// $orderExtendJson = json_decode($item['order_extend_json'],true);
|
|
// $orderExtendJson = json_decode($item['order_extend_json'],true);
|
|
@@ -306,27 +316,6 @@ class KangyangCityController extends Curd{
|
|
throw new BusinessException('付款码无效');
|
|
throw new BusinessException('付款码无效');
|
|
}
|
|
}
|
|
|
|
|
|
- // 组合支付,追加加一条支付记录 pay_detail
|
|
|
|
- if ($params['pay_constitute'] == 'Y' && $qrcodePayAmount > 0 && $params['order_status_payment'] == 'SUCCESS') {
|
|
|
|
- $insertPayDetailData = [
|
|
|
|
- 'join_pay_member_id' => $params['join_order_member_id'],
|
|
|
|
- 'join_pay_order_id' => $params['orderGroupId'],
|
|
|
|
- 'pay_status' => 'SUCCESS',
|
|
|
|
- 'pay_category' => $params['goods_classify'],
|
|
|
|
- 'pay_amount' => $params['order_amount_pay'],
|
|
|
|
- 'pay_paytimes' => date('Y-m-d H:i:s'),
|
|
|
|
- 'pay_prepayid' => $params['pay_category'],
|
|
|
|
- 'pay_json_request' => json_encode($params),
|
|
|
|
- 'pay_json_response' => $params['pay_json_response'],
|
|
|
|
- 'pay_addtimes' => time()
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- PayDetail::insert($insertPayDetailData);
|
|
|
|
-
|
|
|
|
- // 组合支付,还原提交的支付分类
|
|
|
|
- $params['pay_category'] = $submitPayCategory;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// 账户支付的金额
|
|
// 账户支付的金额
|
|
$params['order_amount_pay'] = $accountAmount;
|
|
$params['order_amount_pay'] = $accountAmount;
|
|
}
|
|
}
|
|
@@ -341,31 +330,45 @@ class KangyangCityController extends Curd{
|
|
// 'express' => 'Y',
|
|
// 'express' => 'Y',
|
|
// ]);
|
|
// ]);
|
|
}
|
|
}
|
|
- $params['order_amount_pay'] = $params['order_amount_pay'] + $qrcodePayAmount;
|
|
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
- // 写入主订单
|
|
|
|
- $this->insertMain($params);
|
|
|
|
- // 订单详情
|
|
|
|
- $sheetId = $this->insertSheet($params);
|
|
|
|
|
|
+ // 查询是否有未完全支付订单
|
|
|
|
+ $paidOrder = Order::where('join_order_member_id', $params['join_order_member_id'])
|
|
|
|
+ ->where('order_category', 'VIP')
|
|
|
|
+ ->where('order_status_system', 'PAYING')
|
|
|
|
+ ->first();
|
|
|
|
+
|
|
|
|
+ if (empty($paidOrder)) {
|
|
|
|
+ // 写入主订单
|
|
|
|
+ $this->insertMain($params);
|
|
|
|
+ // 订单详情
|
|
|
|
+ $this->insertSheet($params);
|
|
|
|
+ } else {
|
|
|
|
+ $params['orderGroupId'] = $paidOrder->order_groupby;
|
|
|
|
+ $params['order_amount_paid'] = $paidOrder->order_amount_paid;
|
|
|
|
+ $paidOrder->order_amount_paid = $paidOrder->order_amount_paid + $params['order_amount_pay'];
|
|
|
|
+ $paidOrder->order_amount_pay = $paidOrder->order_amount_paid;
|
|
|
|
+ if (floatval($paidOrder->order_amount_paid) >= $paidOrder->order_amount_total) {
|
|
|
|
+ $paidOrder->order_is_complete = 'Y';
|
|
|
|
+ $paidOrder->order_status_system = 'DONE';
|
|
|
|
+ $paidOrder->order_status_payment = 'SUCCESS';
|
|
|
|
+ // 更新sheet
|
|
|
|
+ OrderSheet::where('join_sheet_order_id', $paidOrder->order_id)->update(['order_sheet_status'=>'DONE']);
|
|
|
|
+ }
|
|
|
|
+ $paidOrder->save();
|
|
|
|
+
|
|
|
|
+ }
|
|
// 支付记录
|
|
// 支付记录
|
|
- $params['order_amount_pay'] = $params['order_amount_pay'] - $qrcodePayAmount;
|
|
|
|
$this->insertPayDetail($params);
|
|
$this->insertPayDetail($params);
|
|
|
|
|
|
- $params['order_express_goods'] = json_encode(['sheet' => [$sheetId]]);
|
|
|
|
|
|
+// $params['order_express_goods'] = json_encode(['sheet' => [$sheetId]]);
|
|
|
|
|
|
// 2.4W 康养城
|
|
// 2.4W 康养城
|
|
- if ($params['goods_classify'] == 'VIP' && $params['order_status_payment'] == 'SUCCESS') {
|
|
|
|
|
|
+ if ($params['goods_classify'] == 'VIP' && $params['order_status_payment'] == 'SUCCESS' && (!empty($paidOrder) && floatval($paidOrder->order_amount_paid) >= $paidOrder->order_amount_total || floatval($params['order_amount_pay']) >= $params['order_amount_total'])) {
|
|
$params['member_id'] = $params['join_order_member_id'];
|
|
$params['member_id'] = $params['join_order_member_id'];
|
|
Event::dispatch('order.kangyangCityVIP.grant', $params);
|
|
Event::dispatch('order.kangyangCityVIP.grant', $params);
|
|
}
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
-
|
|
|
|
- // 会员升级
|
|
|
|
- if (!empty($params['order_is_complete']) && $params['order_is_complete'] == 'Y' && $params['order_status_payment'] == 'SUCCESS') {
|
|
|
|
- Event::dispatch('order.complete', $params);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if ($params['settlement_now'] == 'Y' && $params['order_status_payment'] != 'SUCCESS') {
|
|
if ($params['settlement_now'] == 'Y' && $params['order_status_payment'] != 'SUCCESS') {
|
|
_syslog("订单", "支付异常,检查是否有轮询");
|
|
_syslog("订单", "支付异常,检查是否有轮询");
|
|
return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
@@ -435,6 +438,7 @@ class KangyangCityController extends Curd{
|
|
if ($params['goods_classify'] == 'PACKAGE' && $params['delivery'] == 'ARRIVAL') {
|
|
if ($params['goods_classify'] == 'PACKAGE' && $params['delivery'] == 'ARRIVAL') {
|
|
$systemStatus = "WAITING";
|
|
$systemStatus = "WAITING";
|
|
}
|
|
}
|
|
|
|
+ $paymentStatus = 'PENDING';
|
|
Db::beginTransaction();
|
|
Db::beginTransaction();
|
|
try {
|
|
try {
|
|
// 组合支付时,付款码应收金额
|
|
// 组合支付时,付款码应收金额
|
|
@@ -442,6 +446,7 @@ class KangyangCityController extends Curd{
|
|
if ($params['pay_category'] == 'OFFLINE' || $params['pay_category'] == 'MONEY') {
|
|
if ($params['pay_category'] == 'OFFLINE' || $params['pay_category'] == 'MONEY') {
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
|
+ $paymentStatus = 'SUCCESS';
|
|
if ($params['pay_category'] == 'OFFLINE' && !empty($params['pay_category_sub'])) {
|
|
if ($params['pay_category'] == 'OFFLINE' && !empty($params['pay_category_sub'])) {
|
|
$params['pay_category'] = $params['pay_category_sub'];
|
|
$params['pay_category'] = $params['pay_category_sub'];
|
|
}
|
|
}
|
|
@@ -473,6 +478,7 @@ class KangyangCityController extends Curd{
|
|
} else {
|
|
} else {
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
|
+ $paymentStatus = 'SUCCESS';
|
|
}
|
|
}
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
$params['pay_category'] = 'ALIPAY';
|
|
$params['pay_category'] = 'ALIPAY';
|
|
@@ -485,33 +491,12 @@ class KangyangCityController extends Curd{
|
|
} else {
|
|
} else {
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
|
+ $paymentStatus = 'SUCCESS';
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
throw new BusinessException('付款码无效');
|
|
throw new BusinessException('付款码无效');
|
|
}
|
|
}
|
|
|
|
|
|
- // 组合支付,追加加一条支付记录 pay_detail
|
|
|
|
- if ($params['pay_constitute'] == 'Y' && $qrcodePayAmount > 0) {
|
|
|
|
- $insertPayDetailData = [
|
|
|
|
- 'join_pay_member_id' => $params['join_order_member_id'],
|
|
|
|
- 'join_pay_order_id' => $params['orderGroupId'],
|
|
|
|
- 'pay_status' => 'SUCCESS',
|
|
|
|
- 'pay_category' => $params['goods_classify'],
|
|
|
|
- 'pay_amount' => $params['order_amount_pay'],
|
|
|
|
- 'pay_paytimes' => date('Y-m-d H:i:s'),
|
|
|
|
- 'pay_prepayid' => $params['pay_category'],
|
|
|
|
- 'pay_json_request' => json_encode($params),
|
|
|
|
- 'pay_json_response' => $params['pay_json_response'],
|
|
|
|
- 'join_pay_object_json' => !empty($params['orderId']) ? json_encode(['order_id' => $params['orderId']]) : '[]',
|
|
|
|
- 'pay_addtimes' => time()
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- PayDetail::insert($insertPayDetailData);
|
|
|
|
-
|
|
|
|
- // 组合支付,还原提交的支付分类
|
|
|
|
- $params['pay_category'] = $submitPayCategory;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// 账户支付的金额
|
|
// 账户支付的金额
|
|
$params['order_amount_pay'] = $accountAmount;
|
|
$params['order_amount_pay'] = $accountAmount;
|
|
}
|
|
}
|
|
@@ -524,25 +509,35 @@ class KangyangCityController extends Curd{
|
|
SysDept::where('dept_id', $orderConfigJson['tableid'])->where('dept_category', '桌台')->update(['dept_status' => 'ACTIVED']);
|
|
SysDept::where('dept_id', $orderConfigJson['tableid'])->where('dept_category', '桌台')->update(['dept_status' => 'ACTIVED']);
|
|
}
|
|
}
|
|
$order->order_config_json = json_encode($orderConfigJson);
|
|
$order->order_config_json = json_encode($orderConfigJson);
|
|
- $order->order_amount_pay = $params['order_amount_pay'] + $qrcodePayAmount;
|
|
|
|
|
|
+ $order->order_amount_paid = $order->order_amount_paid + $params['order_amount_pay'];
|
|
|
|
+ $order->order_amount_pay = $order->order_amount_paid;
|
|
// 康养城订单,支付完就结束了
|
|
// 康养城订单,支付完就结束了
|
|
- if ($order->order_status_payment == 'SUCCESS' && $params['goods_classify'] == 'VIP') {
|
|
|
|
|
|
+ if ($order->order_status_payment == 'SUCCESS' && $params['goods_classify'] == 'VIP' && floatval($order->order_amount_paid) >= $order->order_amount_total) {
|
|
$order->order_is_complete = 'Y';
|
|
$order->order_is_complete = 'Y';
|
|
}
|
|
}
|
|
|
|
+ if (floatval($order->order_amount_paid) < $order->order_amount_total) {
|
|
|
|
+ $order->order_status_system = 'PAYING';
|
|
|
|
+ $order->order_status_payment = 'PENDING';
|
|
|
|
+ $order->order_is_complete = 'N';
|
|
|
|
+ }
|
|
// 主订单
|
|
// 主订单
|
|
$order->save();
|
|
$order->save();
|
|
|
|
|
|
// sheet
|
|
// sheet
|
|
if ($order->order_status_payment == 'SUCCESS') {
|
|
if ($order->order_status_payment == 'SUCCESS') {
|
|
- OrderSheet::where('join_sheet_order_id', $params['order_id'])->update([
|
|
|
|
- 'order_sheet_status' => $systemStatus,
|
|
|
|
- ]);
|
|
|
|
|
|
+ $data = [
|
|
|
|
+ 'order_sheet_status'=>$systemStatus
|
|
|
|
+ ];
|
|
|
|
+ if (floatval($order->order_amount_paid) < $order->order_amount_total){
|
|
|
|
+ $data['order_sheet_status'] = 'BEING';
|
|
|
|
+ }
|
|
|
|
+ OrderSheet::where('join_sheet_order_id', $params['order_id'])->update($data);
|
|
}
|
|
}
|
|
// payDetail
|
|
// payDetail
|
|
$payData = [
|
|
$payData = [
|
|
'pay_amount' => $params['order_amount_pay']
|
|
'pay_amount' => $params['order_amount_pay']
|
|
];
|
|
];
|
|
- if ($order->order_status_payment == 'SUCCESS') {
|
|
|
|
|
|
+ if ($paymentStatus == 'SUCCESS') {
|
|
$payData['pay_paytimes'] = date('Y-m-d H:i:s');
|
|
$payData['pay_paytimes'] = date('Y-m-d H:i:s');
|
|
$payData['pay_status'] = 'SUCCESS';
|
|
$payData['pay_status'] = 'SUCCESS';
|
|
}
|
|
}
|
|
@@ -565,26 +560,26 @@ class KangyangCityController extends Curd{
|
|
$payData['pay_prepayid'] = 'MONEY';
|
|
$payData['pay_prepayid'] = 'MONEY';
|
|
}
|
|
}
|
|
// 如果 是APP 过来的菜订单,可能没有paydetail
|
|
// 如果 是APP 过来的菜订单,可能没有paydetail
|
|
- if (!PayDetail::where('join_pay_order_id', $order->order_groupby)->where('pay_category', '<>', 'WXPAY')->where('pay_category', '<>', 'ALIPAY')->exists()) {
|
|
|
|
- $payData['join_pay_member_id'] = $params['join_order_member_id'];
|
|
|
|
- $payData['join_pay_order_id'] = $order->order_groupby;
|
|
|
|
- $payData['pay_status'] = $payData['pay_status'] == 'SUCCESS' ? $payData['pay_status'] : 'WAITING';
|
|
|
|
- $payData['pay_category'] = $params['goods_classify'] ?? '';
|
|
|
|
- $payData['pay_json_request'] = json_encode($params); // {"pay-result": "支付成功", "result-datetime": "2024-07-29 18:38:21"}
|
|
|
|
- $payData['pay_json_response'] = $payData['pay_status'] == 'SUCCESS' ? json_encode([
|
|
|
|
- 'pay-result' => '支付成功', 'result-datetime' => date('Y-m-d H:i:s')
|
|
|
|
- ]) : '[]';
|
|
|
|
- $payData['join_pay_object_json'] = !empty($params['orderId']) ? json_encode(['order_id' => $params['orderId']]) : '[]';
|
|
|
|
- $payData['pay_addtimes'] = time();
|
|
|
|
-
|
|
|
|
- PayDetail::insert($payData);
|
|
|
|
- } else {
|
|
|
|
- // 更新非微信支付宝的支付记录
|
|
|
|
- PayDetail::where('join_pay_order_id', $order->order_groupby)->where('pay_category', '<>', 'WXPAY')->where('pay_category', '<>', 'ALIPAY')->update($payData);
|
|
|
|
- }
|
|
|
|
|
|
+// if (!PayDetail::where('join_pay_order_id', $order->order_groupby)->where('pay_category', '<>', 'WXPAY')->where('pay_category', '<>', 'ALIPAY')->exists()) {
|
|
|
|
+ $payData['join_pay_member_id'] = $params['join_order_member_id'];
|
|
|
|
+ $payData['join_pay_order_id'] = $order->order_groupby;
|
|
|
|
+ $payData['pay_status'] = $payData['pay_status'] == 'SUCCESS' ? $payData['pay_status'] : 'WAITING';
|
|
|
|
+ $payData['pay_category'] = $params['goods_classify'] ?? '';
|
|
|
|
+ $payData['pay_json_request'] = json_encode($params); // {"pay-result": "支付成功", "result-datetime": "2024-07-29 18:38:21"}
|
|
|
|
+ $payData['pay_json_response'] = $payData['pay_status'] == 'SUCCESS' ? json_encode([
|
|
|
|
+ 'pay-result' => '支付成功', 'result-datetime' => date('Y-m-d H:i:s')
|
|
|
|
+ ]) : '[]';
|
|
|
|
+ $payData['join_pay_object_json'] = !empty($params['orderId']) ? json_encode(['order_id' => $params['orderId']]) : '[]';
|
|
|
|
+ $payData['pay_addtimes'] = time();
|
|
|
|
+
|
|
|
|
+ PayDetail::insert($payData);
|
|
|
|
+// } else {
|
|
|
|
+// // 更新非微信支付宝的支付记录
|
|
|
|
+// PayDetail::where('join_pay_order_id', $order->order_groupby)->where('pay_category', '<>', 'WXPAY')->where('pay_category', '<>', 'ALIPAY')->update($payData);
|
|
|
|
+// }
|
|
|
|
|
|
// 2.4W 康养城
|
|
// 2.4W 康养城
|
|
- if ($params['goods_classify'] == 'VIP' && $order->order_status_payment == 'SUCCESS') {
|
|
|
|
|
|
+ if ($params['goods_classify'] == 'VIP' && $order->order_status_payment == 'SUCCESS' && floatval($order->order_amount_paid) >= $order->order_amount_total) {
|
|
$params['member_id'] = $params['join_order_member_id'];
|
|
$params['member_id'] = $params['join_order_member_id'];
|
|
Event::dispatch('order.kangyangCityVIP.grant', $params);
|
|
Event::dispatch('order.kangyangCityVIP.grant', $params);
|
|
}
|
|
}
|
|
@@ -595,7 +590,7 @@ class KangyangCityController extends Curd{
|
|
Event::dispatch('order.complete', $params);
|
|
Event::dispatch('order.complete', $params);
|
|
}
|
|
}
|
|
|
|
|
|
- if ($order->order_status_payment != 'SUCCESS') {
|
|
|
|
|
|
+ if ($order->order_status_payment != 'SUCCESS' && $paymentStatus != 'SUCCESS') {
|
|
_syslog("订单", "支付异常,检查是否有轮询");
|
|
_syslog("订单", "支付异常,检查是否有轮询");
|
|
return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
}
|
|
}
|
|
@@ -651,10 +646,12 @@ class KangyangCityController extends Curd{
|
|
'order_name' => date('Y-m-d H:i:s') . '-订单',
|
|
'order_name' => date('Y-m-d H:i:s') . '-订单',
|
|
'order_amount_total' => $params['order_amount_total'],
|
|
'order_amount_total' => $params['order_amount_total'],
|
|
'order_amount_pay' => $params['order_amount_pay'],
|
|
'order_amount_pay' => $params['order_amount_pay'],
|
|
|
|
+ 'order_amount_paid' => $params['order_amount_pay'],
|
|
'order_category' => $orderCategory,
|
|
'order_category' => $orderCategory,
|
|
- 'order_is_complete' => $params['order_is_complete'] ?? 'N',
|
|
|
|
- 'order_status_system' => $params['order_status_system'],
|
|
|
|
- 'order_status_payment' => $params['order_status_payment'],
|
|
|
|
|
|
+ 'order_classify' => $orderCategory,
|
|
|
|
+ 'order_is_complete' => floatval($params['order_amount_pay']) >= floatval($params['order_amount_total']) ? 'Y' : 'N',
|
|
|
|
+ 'order_status_system' => floatval($params['order_amount_pay']) >= floatval($params['order_amount_total']) ? 'DONE' : 'PAYING',
|
|
|
|
+ 'order_status_payment' => floatval($params['order_amount_pay']) >= floatval($params['order_amount_total']) ? 'SUCCESS' : 'PENDING',
|
|
'order_status_storage' => $params['order_status_storage'],
|
|
'order_status_storage' => $params['order_status_storage'],
|
|
'order_platform' => $params['order_platform'],
|
|
'order_platform' => $params['order_platform'],
|
|
'order_remark' => $params['order_remark'] ?? '',
|
|
'order_remark' => $params['order_remark'] ?? '',
|
|
@@ -695,12 +692,20 @@ class KangyangCityController extends Curd{
|
|
if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS') {
|
|
if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS') {
|
|
$extendJson['table'] = null;
|
|
$extendJson['table'] = null;
|
|
}
|
|
}
|
|
|
|
+ $orderSheetStatus = 'PAYING';
|
|
|
|
+ if ($params['settlement_now'] == 'Y' && $params['order_status_payment'] == 'SUCCESS'){
|
|
|
|
+ if (floatval($params['order_amount_pay']) >= floatval($params['order_amount_total'])){
|
|
|
|
+ $orderSheetStatus = 'DONE';
|
|
|
|
+ }else{
|
|
|
|
+ $orderSheetStatus = 'BEING';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
$data = [
|
|
$data = [
|
|
'join_sheet_member_id' => $params['join_order_member_id'],
|
|
'join_sheet_member_id' => $params['join_order_member_id'],
|
|
'join_sheet_order_id' => $params['orderId'],
|
|
'join_sheet_order_id' => $params['orderId'],
|
|
'join_sheet_goods_id' => $goods['goods_id'],
|
|
'join_sheet_goods_id' => $goods['goods_id'],
|
|
'join_sheet_goods_sku_id' => $goods['sku_id'],
|
|
'join_sheet_goods_sku_id' => $goods['sku_id'],
|
|
- 'order_sheet_status' => $params['settlement_now'] == 'Y' && $params['order_status_payment'] == 'SUCCESS' ? 'DONE' : 'PAYING',
|
|
|
|
|
|
+ 'order_sheet_status' => $orderSheetStatus,
|
|
'order_sheet_category' => (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS') ? 'DISHES' : 'NORMAL',
|
|
'order_sheet_category' => (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS') ? 'DISHES' : 'NORMAL',
|
|
'order_sheet_num' => $goods['nbr'],
|
|
'order_sheet_num' => $goods['nbr'],
|
|
'order_sheet_price' => $goods['goods_sales_price'],
|
|
'order_sheet_price' => $goods['goods_sales_price'],
|
|
@@ -795,4 +800,310 @@ class KangyangCityController extends Curd{
|
|
throw new BusinessException('创建支付记录失败');
|
|
throw new BusinessException('创建支付记录失败');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Desc 订单商品详情
|
|
|
|
+ * @Author Gorden
|
|
|
|
+ * @Date 2024/3/29 8:50
|
|
|
|
+ *
|
|
|
|
+ * @param Request $request
|
|
|
|
+ * @return Response
|
|
|
|
+ */
|
|
|
|
+ public function sheet(Request $request)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $orderId = $request->get('order_id');
|
|
|
|
+ $orderSheet = OrderSheet::with([
|
|
|
|
+ 'member' => function ($query) {
|
|
|
|
+ $query->select('member_id', 'member_mobile', 'member_is_owner', 'join_member_role_id');
|
|
|
|
+ },
|
|
|
|
+ 'goods' => function ($query) {
|
|
|
|
+ $query->select('goods_id', 'goods_name', 'goods_cover', 'goods_market_price', 'goods_sales_price', 'goods_classify', 'goods_if_express');
|
|
|
|
+ },
|
|
|
|
+ 'memberInfo',
|
|
|
|
+ 'cert',
|
|
|
|
+ 'sku' => function ($query) {
|
|
|
|
+ $query->where('goods_sku_status', 'ON')
|
|
|
|
+ ->select('goods_sku_id', 'join_sku_goods_id', 'goods_sku_specs_json', 'goods_sku_sales_price');
|
|
|
|
+ },
|
|
|
|
+ 'skus',
|
|
|
|
+ 'refund' => function ($query) {
|
|
|
|
+ $query->select('join_return_order_id', 'order_return_status');
|
|
|
|
+ }
|
|
|
|
+ ])->where('join_sheet_order_id', $orderId)
|
|
|
|
+ ->orderBy('order_sheet_id', 'DESC')
|
|
|
|
+ ->get()
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
|
|
+ $order = Order::where('order_id', $orderId)->first();
|
|
|
|
+ $express = OrderExpress::where('join_express_order_id', $orderId)->first();
|
|
|
|
+ $premises = '';
|
|
|
|
+ if ($express && $express->order_express_type == '自提') {
|
|
|
|
+ $premises = $express->order_express_company;
|
|
|
|
+ }
|
|
|
|
+ $sheetAmount = 0;
|
|
|
|
+ foreach ($orderSheet as &$item) {
|
|
|
|
+ $sheetAmount += $item['order_sheet_amount'];
|
|
|
|
+ $item['goods']['goods_cover'] = getenv('STORAGE_DOMAIN') . $item['goods']['goods_cover'];
|
|
|
|
+ if (!empty($item['goods']) && $item['goods']['goods_classify'] == 'PACKAGE') {
|
|
|
|
+ $components = GoodsComponent::with('goods')
|
|
|
|
+ ->where('join_component_master_goods_id', $item['goods']['goods_id'])
|
|
|
|
+ ->select('join_component_master_goods_id', 'join_component_goods_id', 'goods_component_price',
|
|
|
|
+ 'goods_component_price', 'goods_component_json')
|
|
|
|
+ ->get()
|
|
|
|
+ ->toArray();
|
|
|
|
+ $goodsArr = [];
|
|
|
|
+ foreach ($components as $component) {
|
|
|
|
+ $configJson = !empty($component['goods_component_json']) ? json_decode($component['goods_component_json'], true) : [];
|
|
|
|
+ if (!empty($component['goods'])) {
|
|
|
|
+ $supplierName = Supplier::where('supplier_id', $component['goods']['join_goods_supplier_id'])->value('supplier_name');
|
|
|
|
+ $benefit = MemberBenefit::where('join_benefit_member_id', $item['join_sheet_member_id'])
|
|
|
|
+ ->where('join_benefit_goods_id', $component['goods']['goods_id'])
|
|
|
|
+ ->where('join_benefit_order_id', $orderId)
|
|
|
|
+ ->first();
|
|
|
|
+ $goodsArr[] = [
|
|
|
|
+ 'goods_name' => $component['goods']['goods_name'],
|
|
|
|
+ 'goods_cover' => getenv('STORAGE_DOMAIN') . $component['goods']['goods_cover'],
|
|
|
|
+ 'supplier_name' => $supplierName,
|
|
|
|
+ 'nbr' => $configJson['nbr'] ?? 0,
|
|
|
|
+ 'used' => !empty($benefit->member_benefit_used_count) ? intval($benefit->member_benefit_used_count) : ''
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $item['goods']['components'] = $goodsArr;
|
|
|
|
+ }
|
|
|
|
+ if (!empty($item['sku'])) {
|
|
|
|
+ if (!empty($item['sku']['goods_sku_specs_json'])) {
|
|
|
|
+ $specsJson = json_decode($item['sku']['goods_sku_specs_json'], true);
|
|
|
|
+ $skuName = '';
|
|
|
|
+ foreach ($specsJson as $specsKey => $skuSpecs) {
|
|
|
|
+ if (is_array($skuSpecs)) {
|
|
|
|
+ $skuName = $skuName . ' ' . implode(' ', $skuSpecs) . ';';
|
|
|
|
+ } else {
|
|
|
|
+ $skuName = $skuName . ' ' . $skuSpecs . ';';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $item['sku']['goods_sku_title'] = rtrim($skuName, ';');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!empty($item['skus'])) {
|
|
|
|
+ foreach ($item['skus'] as $key => $skus) {
|
|
|
|
+ if (!empty($skus['goods_sku_specs_json'])) {
|
|
|
|
+ $item['skus'][$key]['goods_sku_specs_json'] = json_decode($skus['goods_sku_specs_json']);
|
|
|
|
+
|
|
|
|
+ $skuName = '';
|
|
|
|
+ foreach ($item['skus'][$key]['goods_sku_specs_json'] as $specsKey => $skuSpecs) {
|
|
|
|
+ $keyStr = ($specsKey == '规格') ? '' : ($specsKey . ':');
|
|
|
|
+ if (is_array($skuSpecs)) {
|
|
|
|
+ $skuName = $skuName . $keyStr . ' ' . implode(' ', $skuSpecs) . '; ';
|
|
|
|
+ } else {
|
|
|
|
+ $skuName = $skuName . $keyStr . ' ' . $skuSpecs . '; ';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $item['skus'][$key]['sku_name'] = rtrim($skuName, '; ');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $item['skus'] = [];
|
|
|
|
+ }
|
|
|
|
+ if (in_array($item['goods']['goods_classify'], ['SERVICE', 'CHNMED', 'CHNNCD', 'PACKAGE']) && $order->order_status_system == 'DONE') {
|
|
|
|
+ $item['appontment'] = [];
|
|
|
|
+ $appontments = Appointment::where('join_appointment_order_id', $orderId)
|
|
|
|
+ ->where('appointment_status', 'DONE')
|
|
|
|
+ ->select('appointment_status', 'appointment_id', 'appointment_done_datetime', 'appointment_done_json', 'appointment_apply_json')
|
|
|
|
+ ->get()
|
|
|
|
+ ->toArray();
|
|
|
|
+ foreach ($appontments as $appontment) {
|
|
|
|
+ $doneJson = [];
|
|
|
|
+ $username = '';
|
|
|
|
+ if (!empty($appontment['appointment_done_json'])) {
|
|
|
|
+ $doneJson = json_decode($appontment['appointment_done_json'], true);
|
|
|
|
+ if (isset($doneJson['charge'])) {
|
|
|
|
+ $username = SysUser::where('user_id', $doneJson['charge']['charge_user_id'])->value('user_name');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $person = 1;
|
|
|
|
+ if (!empty($appontment->appointment_apply_json)) {
|
|
|
|
+ $applyJson = json_decode($appontment->appointment_apply_json, true);
|
|
|
|
+ if (isset($applyJson['person'])) {
|
|
|
|
+ $person = $applyJson['person'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $item['appontment'][] = [
|
|
|
|
+ 'member' => ($item['cert'] ? $item['cert']['member_cert_name'] . '-' : '') . ($item['member'] ? $item['member']['member_mobile'] : ''),
|
|
|
|
+ 'goods_name' => $item['goods']['goods_name'],
|
|
|
|
+ 'premisses' => isset($doneJson['charge']) ? $doneJson['charge']['charge_premises'] : '',
|
|
|
|
+ 'username' => $username,
|
|
|
|
+ 'nbr' => $person,
|
|
|
|
+ 'done_time' => $appontment['appointment_done_datetime'],
|
|
|
|
+ 'appointment_status' => $appontment['appointment_status'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!empty($item['order_sheet_extend_json']) && !$express) {
|
|
|
|
+ $extendJson = json_decode($item['order_sheet_extend_json'], true);
|
|
|
|
+ if (isset($extendJson['address_id'])) {
|
|
|
|
+ $address = ClientConfig::where('client_config_id', $extendJson['address_id'])->first();
|
|
|
|
+ if (!empty($address)) {
|
|
|
|
+ $valJson = json_decode($address->client_config_val_json, true);
|
|
|
|
+ $express = [
|
|
|
|
+ 'order_express_address' => $valJson['address'] . ($valJson['numbers'] ?? ''),
|
|
|
|
+ 'order_express_city' => $valJson['city'],
|
|
|
|
+ 'order_express_mobile' => $valJson['mobile'],
|
|
|
|
+ 'order_express_person' => $valJson['person']
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $item['member']['level'] = '普通用户';
|
|
|
|
+ if (!empty($item['member']['join_member_role_id'])) {
|
|
|
|
+ $item['member']['level'] = MemberRole::where('member_role_id', $item['member']['join_member_role_id'])->value('member_role_name');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $order->sheet_amount = number_format($sheetAmount, 2);
|
|
|
|
+
|
|
|
|
+ $payDetails = PayDetail::where('join_pay_order_id', $order->order_groupby)
|
|
|
|
+ ->where('pay_category', 'VIP')
|
|
|
|
+ ->where('pay_status', 'SUCCESS')
|
|
|
|
+ ->select('pay_id', 'pay_category', 'pay_prepayid', 'pay_paytimes', 'pay_status', 'pay_amount', 'pay_extend_json')
|
|
|
|
+ ->orderBy('pay_addtimes', 'DESC')
|
|
|
|
+ ->get();
|
|
|
|
+ $order->pay_amount_total = 0;
|
|
|
|
+ foreach ($payDetails as &$payDetail) {
|
|
|
|
+ $categoryArray = explode('-', $payDetail->pay_prepayid);
|
|
|
|
+ if (isset($categoryArray[1])) {
|
|
|
|
+ $payDetail->pay_category = $categoryArray[1];
|
|
|
|
+ } else if (in_array($categoryArray[0], ['WXPAY', 'ALIPAY', 'OFFLINE', 'OFFLINE_ALIPAY', 'OFFLINE_WXPAY', 'MONEY'])) {
|
|
|
|
+ $payDetail->pay_category = $categoryArray[0];
|
|
|
|
+ }
|
|
|
|
+ if (!empty($payDetail->pay_extend_json)) {
|
|
|
|
+ $payExtendJson = json_decode($payDetail->pay_extend_json, true);
|
|
|
|
+ $order->cancel_times = $payExtendJson['cancel_times'] ?? '';
|
|
|
|
+ }
|
|
|
|
+ $order->pay_amount_total += $payDetail->pay_amount;
|
|
|
|
+ }
|
|
|
|
+ $refund = OrderReturn::where('join_return_order_id', $orderId)
|
|
|
|
+ ->select('order_return_status', 'order_return_apply_datetime', 'order_return_apply_json', 'order_return_accept_datetime', 'order_return_refund_json', 'order_return_extend_json')
|
|
|
|
+ ->first();
|
|
|
|
+ if (!empty($refund->order_return_refund_json)) {
|
|
|
|
+ $returnRefundJson = json_decode($refund->order_return_refund_json, true);
|
|
|
|
+ if (isset($returnRefundJson['user_id'])) {
|
|
|
|
+ $userName = SysUser::where('user_id', $returnRefundJson['user_id'])->value('user_name');
|
|
|
|
+ $returnRefundJson['person'] = $userName;
|
|
|
|
+ unset($returnRefundJson['user_id']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $refund->order_return_refund_json = json_encode($returnRefundJson);
|
|
|
|
+ }
|
|
|
|
+ if (!empty($order->order_config_json)) {
|
|
|
|
+ $orderConfigJson = json_decode($order->order_config_json, true);
|
|
|
|
+ if (isset($orderConfigJson['reach'])) {
|
|
|
|
+ $order->reach = $orderConfigJson['reach'];
|
|
|
|
+ }
|
|
|
|
+ if (isset($orderConfigJson['table'])) {
|
|
|
|
+ $order->table = $orderConfigJson['table'];
|
|
|
|
+ }
|
|
|
|
+ if (isset($orderConfigJson['eat'])) {
|
|
|
|
+ $order->eat = $orderConfigJson['eat'];
|
|
|
|
+ }
|
|
|
|
+ if (isset($orderConfigJson['express'])) {
|
|
|
|
+ $order->express = $orderConfigJson['express'];
|
|
|
|
+ }
|
|
|
|
+ if (isset($orderConfigJson['premises'])) {
|
|
|
|
+ $order->premises = $orderConfigJson['premises'];
|
|
|
|
+ }
|
|
|
|
+ if (isset($orderConfigJson['tableid'])) {
|
|
|
|
+ $order->dept_table_id = $orderConfigJson['tableid'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!empty($order->order_extend_json)) {
|
|
|
|
+ $orderExtendJson = json_decode($order->order_extend_json, true);
|
|
|
|
+ $order->referee = $orderExtendJson['referee'] ?? '';
|
|
|
|
+ if (isset($orderExtendJson['cancel_times'])) {
|
|
|
|
+ $order->cancel_times = $orderExtendJson['cancel_times'];
|
|
|
|
+ }
|
|
|
|
+ if (isset($orderExtendJson['free_remark'])) {
|
|
|
|
+ $order->free_remark = $orderExtendJson['free_remark'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $discount = ['coupon_name' => '', 'classify' => '', 'value' => 0];
|
|
|
|
+ if (!empty($order->order_discount_json)) {
|
|
|
|
+ $orderDiscountJson = json_decode($order->order_discount_json, true);
|
|
|
|
+ foreach ($orderDiscountJson as $discountItem) {
|
|
|
|
+ if (!empty($discountItem['coupon_id'])) {
|
|
|
|
+ $coupon = Coupon::where('coupon_id', $discountItem['coupon_id'])
|
|
|
|
+ ->select('coupon_name', 'coupon_classify', 'coupon_category', 'coupon_value', 'coupon_minimum_limit')
|
|
|
|
+ ->first();
|
|
|
|
+ if (!$coupon) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ $classify = CouponService::couponClassifyInfo($coupon->coupon_classify, $coupon->coupon_category, $coupon->coupon_value, $coupon->coupon_minimum_limit);
|
|
|
|
+ $discount['coupon_name'] .= $coupon->coupon_classify . ':' . $coupon->coupon_name . '(优惠¥' . sprintf("%.2f", $discountItem['coupon_value']) . '), ';
|
|
|
|
+ }
|
|
|
|
+ if ($discountItem['coupon_classify'] == '退款') {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (empty($discountItem['coupon_id']) && !empty($discountItem['coupon_classify'])) {
|
|
|
|
+ if (!empty($discountItem['coupon_detail_id'])) {
|
|
|
|
+
|
|
|
|
+ $discount['classify'] .= $discountItem['coupon_detail_id'][0] . '(优惠¥' . sprintf("%.2f", $discountItem['coupon_value']) . '), ';
|
|
|
|
+ } else {
|
|
|
|
+ $discount['classify'] .= $discountItem['coupon_classify'] . '(优惠¥' . sprintf("%.2f", $discountItem['coupon_value']) . '), ';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!empty($discountItem['coupon_value'])) {
|
|
|
|
+ $discount['value'] += $discountItem['coupon_value'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!empty($discount['coupon_name'])) {
|
|
|
|
+ $discount['coupon_name'] = rtrim($discount['coupon_name'], ', ');
|
|
|
|
+ }
|
|
|
|
+ if (!empty($discount['classify'])) {
|
|
|
|
+ $discount['classify'] = rtrim($discount['classify'], ', ');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $discount['value'] = sprintf("%.2f", $discount['value']);
|
|
|
|
+ $order->discount = $discount;
|
|
|
|
+
|
|
|
|
+ $order->premises = $order->premises ?? $premises;
|
|
|
|
+ $data = [
|
|
|
|
+ 'order' => $order,
|
|
|
|
+ 'refund' => json_decode(json_encode($refund)),
|
|
|
|
+ 'sheet' => json_decode(json_encode($orderSheet)),
|
|
|
|
+ 'express' => json_decode(json_encode($express)),
|
|
|
|
+ 'payDetails' => json_decode(json_encode($payDetails))
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ return json_success('', $data);
|
|
|
|
+
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ dump($e->getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Desc 获取分期的订单
|
|
|
|
+ * @Author Gorden
|
|
|
|
+ * @Date 2024/9/10 15:14
|
|
|
|
+ *
|
|
|
|
+ * @param Request $request
|
|
|
|
+ * @return Response
|
|
|
|
+ */
|
|
|
|
+ public function getPaidOrder(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $memberId = $request->get('member_id');
|
|
|
|
+ if (!$memberId){
|
|
|
|
+ return json_fail('参数异常');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $order = Order::where('join_order_member_id',$memberId)
|
|
|
|
+ ->where('order_category','VIP')
|
|
|
|
+ ->where('order_status_system','PAYING')
|
|
|
|
+ ->select('order_id','order_amount_total','order_amount_paid','order_amount_pay')
|
|
|
|
+ ->first();
|
|
|
|
+
|
|
|
|
+ return json_success('',$order);
|
|
|
|
+ }
|
|
}
|
|
}
|