1650 lines
66 KiB
PHP
1650 lines
66 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2020-12-2
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
|
||
namespace app\modules\api\models;
|
||
|
||
use app\components\XtOpenApi;
|
||
use app\components\YopointApi;
|
||
use app\models\auth\RoleUser;
|
||
use app\models\Box;
|
||
use app\models\common\PluginService;
|
||
use app\models\DevList;
|
||
use app\models\integral\Integral;
|
||
use app\models\Level;
|
||
use app\models\Model;
|
||
|
||
use app\models\MsgCentre;
|
||
use app\models\Option;
|
||
use app\models\PaymentOrder;
|
||
use app\models\PaymentOrderUnion;
|
||
use app\models\StoreEarnings;
|
||
use app\models\StoreUser;
|
||
use function AlibabaCloud\Client\value;
|
||
use app\components\FlashStorage;
|
||
use app\components\SiteHelper;
|
||
use app\components\SysConst;
|
||
use app\models\BallCart;
|
||
use app\models\BallMark;
|
||
use app\models\Coach;
|
||
use app\models\Coupon;
|
||
use app\models\Goods;
|
||
use app\models\GoodsHub;
|
||
use app\models\Order;
|
||
use app\models\OrderDetail;
|
||
use app\models\OrderSale;
|
||
use app\models\Store;
|
||
use app\models\UniqueOrderNo;
|
||
use app\models\User;
|
||
use app\components\auth\AToken;
|
||
use app\components\EncryptHelper;
|
||
use app\models\UserBallArm;
|
||
use app\models\UserCoupon;
|
||
use app\models\UserInformation;
|
||
use app\modules\api\components\ApiHelper;
|
||
use app\modules\api\components\GetDistance;
|
||
use app\modules\api\components\Mqtt;
|
||
use yii\data\Pagination;
|
||
use yii\db\Exception;
|
||
|
||
|
||
class OrderForm extends ApiModel
|
||
{
|
||
|
||
public $limit;//条数
|
||
public $page; //页数
|
||
public $pageCount; // 总页数
|
||
|
||
|
||
public $cx_mch_id = 0;
|
||
|
||
|
||
//预定包间
|
||
public $store_id;
|
||
public $box_id;
|
||
|
||
|
||
public $user_id;
|
||
public $plugin_sign;
|
||
public $price; //订单金额
|
||
public $order_id;
|
||
|
||
public $start_time;
|
||
public $end_time;
|
||
|
||
public $status;
|
||
public $is_pay;
|
||
|
||
|
||
//订单状态 0-完成 1-待使用 2-使用中 3-未支付 4-已取消
|
||
const ORDER_OK = 0;
|
||
const ORDER_ING = 1;
|
||
const ORDER_PAY_ING = 2;
|
||
const ORDER_PAY_NO = 3;
|
||
const ORDER_CANCAL = 4;
|
||
|
||
//支付状态 0=未支付,1=已支付
|
||
const PAY_OK = 1;
|
||
const PAY_NO = 0;
|
||
|
||
|
||
//申请退款
|
||
public $refund_price;
|
||
public $remark;
|
||
public $pic_urls;
|
||
public $type;
|
||
|
||
public $renew = 1; //2续单
|
||
|
||
|
||
public $redis_name = 'api:cxgyc:book_box:';
|
||
|
||
public $redis_key_order = 'api:cxgyc:lock_order:';
|
||
|
||
|
||
public $open_type;
|
||
|
||
public $sn;
|
||
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['limit', 'page', 'order_id'], 'integer'],
|
||
[['page'], 'default', 'value' => 1],
|
||
[['limit'], 'default', 'value' => 20],
|
||
|
||
|
||
[['box_id'], 'required', 'on' => 'box_book'], //价格
|
||
[['plugin_sign'], 'required', 'on' => 'box_book'], //商品标识
|
||
[['store_id'], 'required', 'on' => 'box_book'], //门店
|
||
[['start_time'], 'required', 'on' => 'box_book'], //开始时间
|
||
[['end_time'], 'required', 'on' => 'box_book'], //结束时间
|
||
[['order_id', 'user_id'], 'required', 'on' => 'order_buy_goods_view'],
|
||
];
|
||
}
|
||
|
||
|
||
public function scenarios()
|
||
{
|
||
return [
|
||
'box_book' => ['box_id', 'plugin_sign', 'store_id', 'start_time', 'end_time', 'renew'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* 预定包间
|
||
*/
|
||
public function createOrder()
|
||
{
|
||
|
||
if (empty($this->plugin_sign)) {
|
||
return $this->apiReturnError('标识错误');
|
||
}
|
||
|
||
$user = ApiHelper::findOneUser($this->user_id);
|
||
if ($user == null) {
|
||
return $this->apiReturnError('用户错误,请联系管理员');
|
||
}
|
||
|
||
if (strtotime($this->end_time) < time()) {
|
||
return $this->apiReturnError('结束时间不能小于当前时间');
|
||
}
|
||
|
||
|
||
// 把旧数据未支付订单变更为取消状态
|
||
Order::updateAll([
|
||
'cancel_status' => 1,
|
||
'cancel_time' => time(),
|
||
'status' => 3,
|
||
], [
|
||
'plugin_sign' => 'box_book',
|
||
'is_pay' => 0,
|
||
'cancel_status' => 0,
|
||
'is_delete' => 0,
|
||
]);
|
||
|
||
|
||
$level_id = $user['level_id'];
|
||
$level = Level::findOne(['id' => $level_id, 'status' => 1]);
|
||
$level_discount = $level['discount'] ?? 0; //会员折扣
|
||
$integral = Integral::findOne(['user_id' => $this->user_id, 'is_delete' => 0]);
|
||
$user_integral = $integral['account_integral'] ?? 0; //会员积分
|
||
|
||
if (!$this->validate()) {
|
||
return $this->getModelError();
|
||
}
|
||
|
||
//预约开始时间戳跟结束时间戳
|
||
$start_time = strtotime($this->start_time);
|
||
$end_time = strtotime($this->end_time);
|
||
|
||
//检查时间段是否已经被预约
|
||
$query = Order::find()->alias('o')
|
||
->innerJoin(['rt' => OrderDetail::tableName()], 'o.id=rt.order_id')
|
||
->where(['o.store_id' => $this->store_id, 'coach_id' => $this->box_id, 'o.is_delete' => 0, 'o.cancel_status' => 0, 'o.plugin_sign' => 'box_book'])
|
||
->andWhere(['IN', 'o.status', [1, 0]])
|
||
->select('rt.start_at as start,rt.end_at as stop,o.user_id,o.is_pay')
|
||
->asArray()->all();
|
||
|
||
$start = strtotime($this->start_time);
|
||
$end = strtotime($this->end_time);
|
||
|
||
|
||
//预约 $start $end 扣减15分钟保洁 续单时间直接取 $start $end
|
||
if (!empty($query) && $this->renew == 1) {
|
||
$time_arr = [];
|
||
$start_time = strtotime(date('Y-m-d H:i', $start_time));
|
||
while (true) {
|
||
if ($start_time >= $end_time) {
|
||
break;
|
||
}
|
||
$time_arr[$start_time] = 1;
|
||
$start_time += 60 * 60;
|
||
}
|
||
|
||
|
||
$t_arr = [];
|
||
foreach ($query as $key => $val) {
|
||
$t = strtotime(date('Y-m-d H:00', $val['start']));
|
||
while (true) {
|
||
if ($t >= $val['stop']) {
|
||
break;
|
||
}
|
||
// 如果是自己,可以继续选择,并且未支付
|
||
if ($val['user_id'] == $this->user_id && empty($val['is_pay'])) {
|
||
$t_arr[$t] = 0;
|
||
} else {
|
||
$t_arr[$t] = 1;
|
||
}
|
||
$t += 60 * 60;
|
||
}
|
||
|
||
//预约开始时间前面有预约 开始时间往后推15分钟
|
||
if ($start == $val['stop']) {
|
||
$start = $start + 60 * 15;
|
||
}
|
||
|
||
//预约结束时间后面有预约 结束时间往前推15分钟
|
||
if ($end == $val['start']) {
|
||
$end = $end - 60 * 15;
|
||
}
|
||
|
||
}
|
||
|
||
foreach ($time_arr as $key => $val) {
|
||
if (!empty($t_arr[$key])) {
|
||
return $this->apiReturnError('该时间段已有预定,请重新选择');
|
||
}
|
||
}
|
||
}
|
||
|
||
//计算时长
|
||
$duration = $end - $start;
|
||
if ($duration < 60 * 58) {
|
||
return $this->apiReturnError('包厢时间小于1小时,请重新选择');
|
||
}
|
||
|
||
|
||
//订单类型
|
||
$orderType = UniqueOrderNo::ORDER_TYPE_BOOK_BOX;
|
||
$goods_info = '预定包间';
|
||
$boxArr = Box::findOne(['id' => $this->box_id]);
|
||
$this->price = $boxArr['money'];
|
||
|
||
|
||
$duration = $duration / 3600;
|
||
$duration = sprintf("%.1f", $duration);
|
||
|
||
//原价
|
||
$total_price = $this->price * $duration;
|
||
|
||
$user_total_price = 0;
|
||
|
||
//计算出需要支付的现金部分
|
||
if ($user_integral >= $total_price) {
|
||
$total_price_subtract_int = 0;
|
||
$integral = $total_price;//抵扣积分
|
||
} else {
|
||
$total_price_subtract_int = $total_price - $user_integral; //总计价格
|
||
$integral = $user_integral; //抵扣积分
|
||
}
|
||
|
||
if ($total_price_subtract_int > 0 && !empty($level_discount)) {
|
||
$total_price_subtract_int = $total_price_subtract_int * ($level_discount / 100);
|
||
}
|
||
|
||
|
||
try {
|
||
$t = \Yii::$app->db->beginTransaction();
|
||
$order = new Order();
|
||
$order->cx_mch_id = 0;
|
||
$order->user_id = $this->user_id;
|
||
$order->order_no = UniqueOrderNo::generate($orderType, Order::class, 24, 1, 3, 'order_no');
|
||
|
||
$order->express_price = 0;
|
||
$order->express_original_price = 0;
|
||
// $order->total_goods_price = $user_total_price; //订单优惠后 实际支付金额
|
||
$order->total_goods_price = $total_price_subtract_int; //订单优惠后 实际支付金额
|
||
$order->total_goods_original_price = 0;
|
||
$order->use_user_coupon_id = 0;
|
||
$order->coupon_discount_price = 0;
|
||
$order->is_pay = 0;
|
||
$order->pay_type = SysConst::$cxPayTypeWxpay;
|
||
|
||
$order->store_id = $this->store_id;
|
||
$order->coach_id = $this->box_id;
|
||
$order->plugin_sign = $this->plugin_sign;
|
||
$order->created_at = time();
|
||
$order->total_price = $total_price; //总金额 原价
|
||
$order->total_pay_price = 0;
|
||
$order->cancel_status = 0;
|
||
$order->status = 1;
|
||
// $order->integral = $user_integral;
|
||
$order->integral = $integral;
|
||
$order->member_discount = $level_discount;
|
||
|
||
$order->dev_id = 0;
|
||
|
||
if (!$order->save()) {
|
||
$t->rollBack();
|
||
return $this->apiReturnError('创建订单错误', $this->getModelError($order));
|
||
}
|
||
|
||
|
||
$orderdetail = new OrderDetail();
|
||
$orderdetail->cx_mch_id = 0;
|
||
$orderdetail->order_id = $order->id;
|
||
$orderdetail->goods_id = $this->box_id;
|
||
$orderdetail->num = 1;
|
||
$orderdetail->unit_price = 0; //实际支付
|
||
$orderdetail->total_original_price = $user_total_price;
|
||
$orderdetail->total_price = $total_price;
|
||
$orderdetail->plugin_sign = $this->plugin_sign;
|
||
$orderdetail->goods_attr_info = $goods_info;
|
||
|
||
$orderdetail->start_time = date('Y-m-d H:i', $start);
|
||
$orderdetail->end_time = date('Y-m-d H:i', $end);
|
||
|
||
$orderdetail->start_at = $start;
|
||
$orderdetail->end_at = $end;
|
||
|
||
$orderdetail->duration = $duration;
|
||
$orderdetail->created_at = time();
|
||
|
||
|
||
if (!$orderdetail->save()) {
|
||
$t->rollBack();
|
||
return $this->apiReturnError('创建订单错误1', $this->getModelError($orderdetail));
|
||
}
|
||
|
||
$t->commit();
|
||
|
||
|
||
return $this->apiReturnSuccess('ok', ['id' => $order->id, 'pay_status' => $order->is_pay]);
|
||
} catch (Exception $exception) {
|
||
$t->rollBack();
|
||
return [
|
||
'code' => 1,
|
||
'msg' => '创建订单失败' . $exception->getMessage(),
|
||
'data' => null
|
||
];
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 订单列表
|
||
*/
|
||
public function search()
|
||
{
|
||
//plugin_sign 订单标识 box_book 包厢订单
|
||
|
||
if (empty($this->plugin_sign)) {
|
||
return $this->apiReturnError('标识不能为空');
|
||
}
|
||
|
||
|
||
if ($this->plugin_sign == 'box_book') {
|
||
$field = 'o.id as order_id,o.is_sale,o.total_price,rt.goods_id ,
|
||
o.is_pay,o.store_id,o.plugin_sign,s.store_mobile,o.created_at,o.updated_at,o.pay_time,o.integral,
|
||
o.cancel_status,o.status,s.name as store_name,o.store_id,o.total_pay_price,s.city,s.region,o.member_discount,
|
||
s.location_detail,s.cover_pic,b.money as box_money,o.total_goods_price,b.name as box_name,o.cancel_status,b.cover_pic as box_pic,rt.start_time,rt.end_time,rt.duration,b.sn,
|
||
rt.start_at,rt.end_at';
|
||
}
|
||
|
||
|
||
$query = Order::find()->alias('o')
|
||
->leftJoin(['rt' => OrderDetail::tableName()], 'o.id=rt.order_id')
|
||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||
->leftJoin(['b' => Box::tableName()], 'b.id=o.coach_id')
|
||
->where(['o.is_delete' => 0])
|
||
->andWhere(['rt.is_delete' => 0])
|
||
// ->andWhere(['s.is_delete' => 0])
|
||
->andWhere(['rt.plugin_sign' => $this->plugin_sign])
|
||
->andFilterWhere(['o.store_id' => $this->store_id])
|
||
->andFilterWhere(['o.user_id' => $this->user_id])
|
||
->groupBy(['o.id']);
|
||
|
||
|
||
if ($this->status == 1) {
|
||
$query->andWhere(['o.status' => 1, 'is_pay' => 0]);
|
||
} elseif ($this->status == 2) {
|
||
if ($this->plugin_sign == 'box_book') {
|
||
$query->andWhere(['o.is_pay' => 1])
|
||
->andWhere([
|
||
'in', 'o.status', [0, 1]
|
||
]);
|
||
} else {
|
||
$query->andWhere(['o.status' => 1, 'is_pay' => 1]);
|
||
}
|
||
} elseif ($this->status == 3) {
|
||
$query->andWhere(['o.status' => [2, 3]]);
|
||
}
|
||
$query->select($field);
|
||
$count_query = clone $query;
|
||
$count = $count_query->count();
|
||
|
||
if (empty($this->limit)) {
|
||
$this->limit = 10;
|
||
}
|
||
if (empty($this->page)) {
|
||
$this->page = 1;
|
||
}
|
||
|
||
$pagination = new Pagination(['pageSize' => $this->limit, 'totalCount' => $count, 'page' => $this->page - 1]);
|
||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.id' => SORT_DESC])->asArray()->all();
|
||
$this->pageCount = $pagination->pageCount;
|
||
|
||
$orderTimeoutCancel = SiteHelper::getCustomiseOptionByKey("orderTimeoutCancel", "hump"); //订单取消周期
|
||
$orderSalesTime = SiteHelper::getCustomiseOptionByKey("orderSalesTime", "hump"); //可申请售后时间
|
||
|
||
|
||
$orderTimeoutCancel = $orderTimeoutCancel * 60;
|
||
$temp_data = [];
|
||
foreach ($list as $key => $value) {
|
||
|
||
$timeout_cancel = floor(($value['created_at'] + $orderTimeoutCancel) - time());
|
||
$timeout_cancel = $timeout_cancel <= 0 || $value['is_pay'] == 1 || $value['status'] != 1 ? 0 : $timeout_cancel;
|
||
$list[$key]['timeout_cancel'] = $timeout_cancel;
|
||
|
||
$list[$key]['sale_button'] = false;
|
||
$time = $value['pay_time'] + ($orderSalesTime * 60);
|
||
if ($time > time() && $value['total_goods_price'] > 0 && $value['status'] == 0) {
|
||
$list[$key]['sale_button'] = true;
|
||
}
|
||
|
||
$sn = $value['sn'];
|
||
unset($value['sn']);
|
||
|
||
$list[$key]['box_pic'] = SiteHelper::getFullUrl($value['box_pic']);
|
||
//status 订单状态:0=已完成 1=进行中,2-用户申请售后 3-用户取消(超时未支付) 4-订单过期(支付未使用)
|
||
//cancel_status 订单取消状态:0=未取消,1=已取消,2=申请取消
|
||
//is_pay 0=未支付,1=已支付
|
||
|
||
$list[$key]['status_cn'] = '已完成';
|
||
|
||
$list[$key]['cover_pic'] = substr($list[$key]['cover_pic'], 0, 7) == 'http://' ? $list[$key]['cover_pic'] : SiteHelper::getFullUrl($list[$key]['cover_pic']);
|
||
// $list[$key]['cover_pic'] = SiteHelper::getFullUrl($list[$key]['cover_pic']);
|
||
|
||
|
||
$list[$key]['box_pic'] = SiteHelper::getFullUrl($list[$key]['box_pic']);
|
||
$list[$key]['created_at'] = date('Y-m-d H:i:s', $list[$key]['created_at']);
|
||
$list[$key]['updated_at'] = date('Y-m-d H:i:s', $list[$key]['updated_at']);
|
||
$list[$key]['total_goods_price'] = sprintf("%.2f", $list[$key]['total_goods_price']);
|
||
$list[$key]['total_price'] = sprintf("%.2f", $list[$key]['total_price']);
|
||
if ($list[$key]['is_pay'] == 1) {
|
||
$list[$key]['pay_time'] = date('Y-m-d H:i:s', $list[$key]['pay_time']);
|
||
}
|
||
|
||
|
||
//待支付 status = 1 is_pay = 0
|
||
if ($value['status'] == self::ORDER_ING && $value['is_pay'] == self::ORDER_OK && $value['cancel_status'] == self::ORDER_OK && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$list[$key]['status_cn'] = '待支付';
|
||
$temp_data['box_wait_ing'][] = $list[$key];
|
||
}
|
||
|
||
|
||
//已支付 进行中 status = 1 is_pay = 1
|
||
if ($value['status'] == self::ORDER_ING && $value['is_pay'] == self::ORDER_ING && $value['cancel_status'] == self::ORDER_OK && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
|
||
$list[$key]['status_cn'] = '已预约';
|
||
$list[$key]['rabbit_sn'] = $sn;
|
||
if ($value['start_at'] - 60 * 15 < time() && $value['end_at'] > time()) {
|
||
$list[$key]['status_cn'] = '查看二维码';
|
||
}
|
||
$temp_data['box_ing'][] = $list[$key];
|
||
|
||
|
||
}
|
||
|
||
//已完成 status = 0 is_pay = 1 cancel_status = 0
|
||
if ($value['status'] == self::ORDER_OK && $value['is_pay'] == self::PAY_OK && $value['cancel_status'] == self::ORDER_OK && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$list[$key]['status_cn'] = '已完成';
|
||
$temp_data['box_ok'][] = $list[$key];
|
||
}
|
||
|
||
//用户申请售后 status=2 is_sale = 0
|
||
if ($value['status'] == self::ORDER_PAY_ING && $value['is_sale'] == self::PAY_NO && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$list[$key]['status_cn'] = '售后中';
|
||
$temp_data['box_sale'][] = $list[$key];
|
||
}
|
||
|
||
//订单已售后 status=0 is_sale=1
|
||
if ($value['status'] == self::ORDER_OK && $value['is_sale'] == self::PAY_OK && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$list[$key]['status_cn'] = '已售后';
|
||
$temp_data['box_sale'][] = $list[$key];
|
||
}
|
||
|
||
//订单已取消 status = 3 is_pay = 0 超时未支付 cancel_status = 1
|
||
if ($value['status'] == 3 && $value['is_pay'] == self::ORDER_OK && $value['cancel_status'] == 1 && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$list[$key]['status_cn'] = '已取消';
|
||
}
|
||
|
||
//订单已过期 status = 4 is_pay = 1
|
||
if ($value['status'] == 4 && $value['is_pay'] == self::ORDER_ING && $value['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$list[$key]['status_cn'] = '已过期';
|
||
}
|
||
}
|
||
|
||
// if ($this->status != '') {
|
||
// $list = [];
|
||
// $list = array_merge($list, $temp_data['user_ball_return'] ?? []); //还车
|
||
// $list = array_merge($list, $temp_data['user_ball_sale'] ?? []); //售后
|
||
// $list = array_merge($list, $temp_data['user_ball_ing'] ?? []); //租赁中
|
||
// $list = array_merge($list, $temp_data['user_ball_ok'] ?? []); //完成
|
||
// }
|
||
|
||
|
||
$end_flag = $this->page >= $pagination->pageCount ? true : false;
|
||
|
||
return [
|
||
'code' => 0,
|
||
'msg' => 'ok',
|
||
'data' => $list,
|
||
'count' => $count,
|
||
'page_size' => $this->limit,
|
||
'page_count' => $this->pageCount,
|
||
'page_no' => $this->page,
|
||
'end_flag' => $end_flag,
|
||
// 'sql' => $query->createCommand()->getRawSql(),
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* 订单详情
|
||
*/
|
||
public function searchOne()
|
||
{
|
||
if (!$this->order_id) {
|
||
return [
|
||
'code' => 1,
|
||
'msg' => '订单ID不能为空'
|
||
];
|
||
}
|
||
|
||
$user = ApiHelper::findOneUser($this->user_id, $this->cx_mch_id);
|
||
if ($user == null) {
|
||
return [
|
||
'code' => 1,
|
||
'msg' => '用户不存在'
|
||
];
|
||
}
|
||
|
||
if (empty($this->plugin_sign)) {
|
||
return $this->apiReturnError('标识不能为空');
|
||
}
|
||
|
||
|
||
if ($this->plugin_sign == 'box_book') {
|
||
$field = 'o.id as order_id,o.order_no,o.is_sale,o.total_pay_price,o.total_price,rt.goods_id ,
|
||
o.is_pay,o.store_id,o.plugin_sign,s.store_mobile,o.created_at,o.updated_at,o.pay_time,o.pay_type,o.integral,
|
||
o.cancel_status,o.status,s.name as store_name,o.store_id,o.total_pay_price,s.city,s.region,o.member_discount,o.total_goods_price,o.total_goods_original_price,
|
||
s.location_detail,s.cover_pic,b.money as box_money,b.name as box_name,o.cancel_status,b.cover_pic as box_pic,rt.start_time,rt.end_time,rt.duration,b.sn,rt.start_at,rt.end_at';
|
||
}
|
||
|
||
|
||
$orderData = Order::find()->alias('o')
|
||
->leftJoin(['rt' => OrderDetail::tableName()], 'o.id=rt.order_id')
|
||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||
->leftJoin(['b' => Box::tableName()], 'b.id=o.coach_id')
|
||
->where(['o.is_delete' => 0])
|
||
->andWhere(['rt.is_delete' => 0])
|
||
->select($field)
|
||
->where(['o.id' => $this->order_id])->asArray()->one();
|
||
|
||
|
||
$orderTimeoutCancel = SiteHelper::getCustomiseOptionByKey("orderTimeoutCancel", "hump"); //订单取消周期
|
||
$orderSalesTime = SiteHelper::getCustomiseOptionByKey("orderSalesTime", "hump"); //可申请售后时间
|
||
|
||
|
||
$orderTimeoutCancel = $orderTimeoutCancel * 60;
|
||
|
||
$xtOpenApi = new XtOpenApi();
|
||
|
||
|
||
if ($orderData) {
|
||
$orderData['discount_money'] = sprintf("%.2f", $orderData['total_price'] - $orderData['integral'] - $orderData['total_goods_price']);
|
||
$orderData['total_goods_price'] = sprintf("%.2f", $orderData['total_goods_price']);
|
||
$orderData['total_price'] = sprintf("%.2f", $orderData['total_price']);
|
||
|
||
$orderData['account_integral'] = empty($user->integral) ? 0 : $user->integral->account_integral;
|
||
$orderData['account_integral'] = substr(sprintf("%.3f", $orderData['account_integral']), 0, -1);
|
||
$orderData['integral'] = sprintf("%.2f", $orderData['integral']);
|
||
|
||
$timeout_cancel = floor(($orderData['created_at'] + $orderTimeoutCancel) - time());
|
||
$timeout_cancel = $timeout_cancel <= 0 || $orderData['is_pay'] == 1 || $orderData['status'] != 1 ? 0 : $timeout_cancel;
|
||
$orderData['timeout_cancel'] = $timeout_cancel;
|
||
|
||
$orderData['sale_button'] = false;
|
||
$time = $orderData['pay_time'] + ($orderSalesTime * 60);
|
||
|
||
if ($time > time() && $orderData['total_goods_price'] > 0 && $orderData['status'] == 0) {
|
||
$orderData['sale_button'] = true;
|
||
}
|
||
|
||
$orderData['open_show'] = false;
|
||
|
||
$open_time = strtotime($orderData['end_time']);
|
||
$end_time = time();
|
||
|
||
$sn = $orderData['sn'];
|
||
unset($orderData['sn']);
|
||
$orderData['rabbit_sn'] = "";
|
||
$orderData['open_show'] = false;
|
||
|
||
$orderData['status_cn'] = '已完成';
|
||
$orderData['created_at'] = date('Y-m-d H:i:s', $orderData['created_at']);
|
||
$orderData['updated_at'] = date('Y-m-d H:i:s', $orderData['updated_at']);
|
||
|
||
|
||
$orderData['cover_pic'] = substr($orderData['cover_pic'], 0, 7) == 'http://' ?$orderData['cover_pic'] : SiteHelper::getFullUrl($orderData['cover_pic']);
|
||
// $orderData['cover_pic'] = SiteHelper::getFullUrl($orderData['cover_pic']);
|
||
|
||
|
||
$orderData['box_pic'] = SiteHelper::getFullUrl($orderData['box_pic']);
|
||
if (empty($orderData['pay_time'])) {
|
||
$orderData['pay_time'] = $orderData['created_at'];
|
||
|
||
} else {
|
||
$orderData['pay_time'] = date('Y-m-d H:i:s', $orderData['pay_time']);
|
||
}
|
||
|
||
|
||
//待支付 status = 1 is_pay = 0
|
||
if ($orderData['status'] == self::ORDER_ING && $orderData['is_pay'] == self::ORDER_OK && $orderData['cancel_status'] == self::ORDER_OK && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '待支付';
|
||
}
|
||
|
||
|
||
//已支付 进行中 status = 1 is_pay = 1
|
||
if ($orderData['status'] == self::ORDER_ING && $orderData['is_pay'] == self::ORDER_ING && $orderData['cancel_status'] == self::ORDER_OK && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '已预约';
|
||
$orderData['open_show'] = true;
|
||
if ($orderData['start_at'] - 60 * 15 < time() && $orderData['end_at'] > time()) {
|
||
|
||
|
||
//小兔开门
|
||
$xtOpenApi->user_id = $this->user_id;
|
||
$xtQr_ = $xtOpenApi->OpenQr($sn, $open_time);
|
||
$xtQr = !isset($xtQr_['data']['qr']) ? '' : $xtQr_['data']['qr'];
|
||
$orderData['sn'] = $sn;
|
||
$orderData['rabbit_sn'] = $xtQr;
|
||
//当前时间 大于 预约的结束时间
|
||
/*if ($orderData['end_at'] > time()) {
|
||
$orderData['open_show'] = false;
|
||
}*/
|
||
}
|
||
}
|
||
|
||
//已完成 status = 0 is_pay = 1 cancel_status = 0
|
||
if ($orderData['status'] == self::ORDER_OK && $orderData['is_pay'] == self::PAY_OK && $orderData['cancel_status'] == self::ORDER_OK && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '已完成';
|
||
$orderData['open_show'] = true;
|
||
/*if($orderData['start_at']-60*15 < time() && $orderData['end_at'] > time()){
|
||
//小兔开门
|
||
$xtOpenApi->user_id = $this->user_id;
|
||
$xtQr_ = $xtOpenApi->OpenQr($sn, $open_time);
|
||
$xtQr = !isset($xtQr_['data']['qr']) ? '' : $xtQr_['data']['qr'];
|
||
$orderData['sn'] = $sn;
|
||
$orderData['rabbit_sn'] = $xtQr;
|
||
}*/
|
||
}
|
||
|
||
//用户申请售后 status=2 is_sale = 0
|
||
if ($orderData['status'] == self::ORDER_PAY_ING && $orderData['is_sale'] == self::PAY_NO && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '售后中';
|
||
}
|
||
|
||
//订单已售后 status=0 is_sale=1
|
||
if ($orderData['status'] == self::ORDER_OK && $orderData['is_sale'] == self::PAY_OK && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '已售后';
|
||
}
|
||
|
||
//订单已取消 status = 3 is_pay = 0 超时未支付 cancel_status = 1
|
||
if ($orderData['status'] == 3 && $orderData['is_pay'] == self::ORDER_OK && $orderData['cancel_status'] == 1 && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '已取消';
|
||
}
|
||
|
||
//订单已过期 status = 4 is_pay = 1
|
||
if ($orderData['status'] == 4 && $orderData['is_pay'] == self::ORDER_ING && $orderData['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$orderData['status_cn'] = '已过期';
|
||
}
|
||
|
||
$pay_type_arr = [
|
||
0 => '余额支付',
|
||
1 => '微信支付',
|
||
2 => '支付宝支付',
|
||
3 => '银行卡支付',
|
||
4 => '积分支付',
|
||
5 => '银联支付',
|
||
6 => '微信支付分',
|
||
7 => '微信支付',
|
||
];
|
||
$orderData['pay_type'] = $pay_type_arr[$orderData['pay_type']] ?? '';
|
||
if (in_array($orderData['status'], [4, 5])) {
|
||
// 已取消、待支付
|
||
$orderData['pay_type'] = '';
|
||
$orderData['pay_time'] = '';
|
||
}
|
||
if (empty($orderData['member_discount'])) {
|
||
$orderData['member_discount'] = "";
|
||
}
|
||
|
||
}
|
||
|
||
return $this->apiReturnSuccess('ok', $orderData);
|
||
}
|
||
|
||
|
||
public function findOne()
|
||
{
|
||
|
||
|
||
if (empty($this->plugin_sign)) {
|
||
return $this->apiReturnError('标识不能为空');
|
||
}
|
||
|
||
if ($this->plugin_sign != 'box_book') {
|
||
return $this->apiReturnError('标识错误');
|
||
}
|
||
|
||
if (empty($this->store_id)) {
|
||
return $this->apiReturnError('门店错误');
|
||
}
|
||
|
||
if ($this->plugin_sign == 'box_book') {
|
||
$field = 'o.id as order_id,o.order_no,o.is_sale,o.total_pay_price,o.total_price,rt.goods_id ,
|
||
o.is_pay,o.store_id,o.plugin_sign,s.store_mobile,o.created_at,o.updated_at,o.pay_time,o.integral,
|
||
o.cancel_status,o.status,s.name as store_name,o.store_id,o.total_pay_price,s.city,s.region,o.member_discount,o.total_goods_price,o.total_goods_original_price,
|
||
s.location_detail,s.cover_pic,b.money as box_money,b.name as box_name,o.cancel_status,b.cover_pic as box_pic,o.coach_id,rt.start_time,rt.end_time,rt.duration,b.sn,rt.start_at,rt.end_at';
|
||
}
|
||
|
||
$orderData = Order::find()->alias('o')
|
||
->leftJoin(['rt' => OrderDetail::tableName()], 'o.id=rt.order_id')
|
||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||
->leftJoin(['b' => Box::tableName()], 'b.id=o.coach_id')
|
||
->where(['o.is_delete' => 0])
|
||
->andWhere(['rt.is_delete' => 0])
|
||
->select($field)
|
||
->andWhere(['o.store_id' => $this->store_id])
|
||
->andWhere(['o.is_pay' => 1, 'o.status' => 1, 'o.user_id' => $this->user_id])
|
||
->orderBy(['o.id' => SORT_DESC])
|
||
->asArray()->one();
|
||
if (empty($orderData)) {
|
||
return $this->apiReturnSuccess('ok', [
|
||
'open_status' => 2,
|
||
'box_id' => "",
|
||
'order_id' => "",
|
||
'sn' => "",
|
||
'open_type' => '1',
|
||
]);
|
||
}
|
||
$status = 2;
|
||
$time = time();
|
||
$begin_time = $orderData['start_at'] - 60 * 15;
|
||
$end_time = $orderData['end_at'];
|
||
if ($time >= $begin_time && $time <= $end_time) {
|
||
$status = 1;
|
||
}
|
||
return $this->apiReturnSuccess('ok', [
|
||
'open_status' => $status,
|
||
'box_id' => $orderData['coach_id'],
|
||
'order_id' => $orderData['order_id'],
|
||
'sn' => $orderData['sn'],
|
||
'open_type' => '1',
|
||
]);
|
||
}
|
||
|
||
|
||
/**
|
||
* 更新订单状态
|
||
*/
|
||
public function orderSave()
|
||
{
|
||
$orderData = Order::find()
|
||
->select('id,created_at')
|
||
->where(['user_id' => $this->user_id, 'is_pay' => 0, 'status' => 1])->asArray()->all();
|
||
foreach ($orderData as $key => $value) {
|
||
$end_time = $value['created_at'] + 900; //结束时间
|
||
$time = time(); //当前时间
|
||
//结束时间 小于当前时间 订单过期未支付 更新订单状态
|
||
if ($end_time - $time < 0) {
|
||
Order::updateAll(['cancel_status' => 1, 'cancel_time' => $time, 'updated_at' => $time, 'status' => 0], ['id' => $value['id']]);
|
||
}
|
||
}
|
||
return $this->apiReturnSuccess("ok");
|
||
}
|
||
|
||
/**
|
||
* 取消订单
|
||
* @return array
|
||
*/
|
||
public function orderCancal()
|
||
{
|
||
|
||
$orderData = Order::findOne(['id' => $this->order_id]);
|
||
if ($orderData == null) {
|
||
return $this->apiReturnError('错误订单');
|
||
}
|
||
if ($orderData['is_pay'] == 1) {
|
||
return $this->apiReturnError('订单已支付');
|
||
}
|
||
$orderData->status = 3;
|
||
$orderData->cancel_status = 1;
|
||
$orderData->cancel_time = time();
|
||
$orderData->updated_at = time();
|
||
if (!$orderData->save()) {
|
||
return $this->getModelError($orderData);
|
||
}
|
||
return [
|
||
'code' => 0,
|
||
'msg' => '取消成功'
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* 用户申请售后
|
||
* @return array
|
||
*/
|
||
public function orderSales()
|
||
{
|
||
|
||
//金额 原因 补充 图片
|
||
|
||
if (empty($this->plugin_sign) || $this->plugin_sign != 'order_sale') {
|
||
return $this->apiReturnError('标识错误');
|
||
}
|
||
|
||
if (empty($this->type)) {
|
||
return $this->apiReturnError('退款原因不能为空');
|
||
}
|
||
|
||
if (empty($this->order_id)) {
|
||
return $this->apiReturnError('订单ID不能为空');
|
||
}
|
||
|
||
//加锁
|
||
$redis_key = $this->redis_key_order . $this->user_id . $this->plugin_sign;
|
||
$this->lock($redis_key);
|
||
|
||
$orderData = Order::findOne(['id' => $this->order_id, 'user_id' => $this->user_id]);
|
||
if ($orderData == null) {
|
||
return $this->apiReturnError('错误订单');
|
||
}
|
||
//要已完成订单才能发起售后退款
|
||
if ($orderData['is_pay'] != 1) {
|
||
return $this->apiReturnError('该订单未支付,不能发起售后');
|
||
}
|
||
|
||
if ($orderData['is_sale'] == 1) {
|
||
return $this->apiReturnError('订单已处理,请勿重复申请');
|
||
}
|
||
|
||
$orderSaleData = OrderSale::find()->andWhere([
|
||
'user_id' => $this->user_id, 'order_id' => $this->order_id
|
||
])->andWhere([
|
||
'in', 'status', [1, 2]
|
||
])->select('*')->asArray()->one();
|
||
if (!empty($orderSaleData)) {
|
||
if ($orderSaleData['status'] == 2) {
|
||
return $this->apiReturnError('已退款成功');
|
||
}
|
||
return $this->apiReturnError('您已申请退款,请等待门店人员审核');
|
||
}
|
||
|
||
try {
|
||
$t = \Yii::$app->db->beginTransaction();
|
||
$orderData->status = 2;
|
||
if (!$orderData->save()) {
|
||
$t->rollBack();
|
||
return $this->getModelError($orderData);
|
||
}
|
||
|
||
|
||
$orderSaleModel = new OrderSale();
|
||
$orderSaleModel->user_id = $this->user_id;
|
||
$orderSaleModel->order_id = $this->order_id;
|
||
$orderSaleModel->refund_price = $orderData->total_goods_price; //退款金额
|
||
$orderSaleModel->type = $this->type;
|
||
$orderSaleModel->store_id = $orderData['store_id'];
|
||
$orderType = UniqueOrderNo::ORDER_TYPE_BOOK_BOX;
|
||
$orderSaleModel->order_no = UniqueOrderNo::generate($orderType, Order::class, 24, 1, 3, 'order_no');
|
||
if ($this->remark) {
|
||
$orderSaleModel->remark = $this->remark; //退款说明
|
||
}
|
||
if ($this->pic_urls) {
|
||
$orderSaleModel->pic_urls = $this->pic_urls; //补充图片
|
||
}
|
||
$orderSaleModel->created_at = time();
|
||
$orderSaleModel->status_time = 0;
|
||
$orderSaleModel->updated_at = 0;
|
||
$orderSaleModel->deleted_at = 0;
|
||
if (!$orderSaleModel->save()) {
|
||
$t->rollBack();
|
||
return $this->getModelError($orderSaleModel);
|
||
}
|
||
|
||
$t->commit();
|
||
} catch (Exception $exception) {
|
||
$t->rollBack();
|
||
return [
|
||
'code' => 1,
|
||
'msg' => '申请退款成功' . $exception->getMessage(),
|
||
'data' => null
|
||
];
|
||
|
||
}
|
||
return [
|
||
'code' => 0,
|
||
'msg' => '申请退款成功'
|
||
];
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 售后审核
|
||
* @return array
|
||
*/
|
||
public function orderSalesStore()
|
||
{
|
||
if ($this->user_type != 2 && $this->store_type == 2) {
|
||
return $this->apiReturnError('权限错误');
|
||
}
|
||
//金额 原因 补充 图片
|
||
if (empty($this->plugin_sign) || $this->plugin_sign != 'order_sale_store') {
|
||
return $this->apiReturnError('标识错误');
|
||
}
|
||
|
||
|
||
//加锁
|
||
$redis_key = $this->redis_key_order . $this->user_id . $this->plugin_sign;
|
||
$this->lock($redis_key);
|
||
if (!$this->validate()) {
|
||
return $this->getModelError();
|
||
}
|
||
|
||
if (!$this->validate()) {
|
||
return $this->getModelError();
|
||
}
|
||
//售后订单
|
||
// $orderData = OrderSale::findOne(['order_id' => $this->order_id]);
|
||
$orderData = OrderSale::find()->andWhere(['order_id' => $this->order_id, 'is_delete' => 0,])->orderBy(['id' => SORT_DESC])->one();
|
||
|
||
//订单
|
||
$orderObj = Order::findOne(['id' => $this->order_id]);
|
||
|
||
|
||
$orderDetailObj = OrderDetail::findOne(['order_id' => $this->order_id]);
|
||
//球车信息
|
||
$ballCart = BallCart::findOne(['ball_number' => $orderDetailObj->goods_id]);
|
||
|
||
if ($orderData == null || $orderObj == null || $orderDetailObj == null || $ballCart == null) {
|
||
return $this->apiReturnError('错误订单');
|
||
}
|
||
|
||
if ($orderData->status != 1) {
|
||
return $this->apiReturnError('售后订单已完成');
|
||
}
|
||
|
||
|
||
//TODO 支付退款 改变用户金额 改变订单状态
|
||
|
||
try {
|
||
$t = \Yii::$app->db->beginTransaction();
|
||
|
||
//拒绝
|
||
if ($this->status == 3) {
|
||
if (!$this->merchant_remark) {
|
||
return $this->apiReturnError('拒绝原因不能为空');
|
||
}
|
||
$orderObj->is_sale = 2;
|
||
$orderData->merchant_remark = $this->merchant_remark;
|
||
}
|
||
|
||
$orderData->merchant_remark = $this->merchant_remark == null ? '同意' : $this->merchant_remark;
|
||
//更新售后订单表
|
||
$orderData->status = $this->status;
|
||
$orderData->status_time = time();
|
||
$orderData->updated_at = time();
|
||
if (!$orderData->save()) {
|
||
$t->rollBack();
|
||
return $this->getModelError($orderData);
|
||
}
|
||
|
||
//更改订单状态为已完成
|
||
$orderObj->status = 0;
|
||
//同意
|
||
if ($this->status == 2) {
|
||
$orderObj->is_sale = 1;
|
||
}
|
||
$orderObj->updated_at = time();
|
||
if (!$orderObj->save()) {
|
||
$t->rollBack();
|
||
return $this->getModelError($orderObj);
|
||
}
|
||
|
||
//更改球车状态为正常
|
||
$ballCart->status = 0;
|
||
if (!$ballCart->save()) {
|
||
$t->rollBack();
|
||
return $this->getModelError($ballCart);
|
||
}
|
||
MsgCentre::deleteAll(['object_id' => $orderObj->id, 'type' => 3]);
|
||
\Yii::info($orderObj->id . '__进入小程序管理员确认售后用户结果通知', 'wx_applet_msg');
|
||
if ($this->status == 2) {
|
||
$name = "同意";
|
||
|
||
$paymentOrder = PaymentOrder::findOne(['order_no' => $orderObj->order_no]);
|
||
if ($paymentOrder != null) {
|
||
$paymentOrderUnion = PaymentOrderUnion::findOne(['id' => $paymentOrder->payment_order_union_id]);
|
||
if ($paymentOrderUnion != null) {
|
||
$plugin = new \app\models\common\PluginService();
|
||
$wxmpService = $plugin->getWxmpService(0);
|
||
// $url = \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/notify/payment/wxpay-order-refunds';
|
||
$res = $wxmpService->pay->refund([
|
||
'out_trade_no' => $paymentOrderUnion->out_trade_no,
|
||
'out_refund_no' => $paymentOrderUnion->order_no,
|
||
'total_fee' => $paymentOrderUnion->amount * 100,
|
||
'refund_fee' => $paymentOrderUnion->amount * 100,
|
||
// 'notify_url' => $url,
|
||
]);
|
||
if (isset($res['return_code']) && $res['return_code'] != 'SUCCESS') {
|
||
\Yii::info($orderObj->order_no . '__' . $res['return_code'] . '__' . $res['return_msg'], 'refund');
|
||
$t->rollBack();
|
||
return $this->apiReturnError($res['return_msg']);
|
||
}
|
||
$exists = StoreEarnings::find()->where(['order_id' => $orderObj->id, 'is_delete' => 0])->exists();
|
||
if ($exists) {
|
||
\Yii::$app->db->createCommand()->update(StoreEarnings::tableName(), ['is_delete' => 1], ['order_id' => $orderObj->id, 'is_delete' => 0])->execute();
|
||
}
|
||
}
|
||
}
|
||
|
||
} else {
|
||
$name = '拒绝';
|
||
}
|
||
if (!empty($this->merchant_remark)) {
|
||
$merchant_remark = mb_substr($this->merchant_remark, 0, 10);
|
||
} else {
|
||
$merchant_remark = $name;
|
||
}
|
||
MsgCentreForm::sendWxAppletStoreSalesMsg($orderObj, $orderData, $name, $merchant_remark);
|
||
$t->commit();
|
||
} catch (Exception $exception) {
|
||
$t->rollBack();
|
||
return [
|
||
'code' => 1,
|
||
'msg' => '操作失败' . $exception->getMessage(),
|
||
'data' => null
|
||
];
|
||
}
|
||
|
||
|
||
return [
|
||
'code' => 0,
|
||
'msg' => '操作成功'
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* 售后订单列表
|
||
*/
|
||
public function saleList()
|
||
{
|
||
//金额 原因 补充 图片
|
||
if (empty($this->plugin_sign) || $this->plugin_sign != 'sale_list') {
|
||
return $this->apiReturnError('标识错误');
|
||
}
|
||
|
||
|
||
$query = Order::find()->alias('o')
|
||
->join('left join', ['od' => OrderDetail::tableName()], 'o.id = od.order_id')
|
||
->join('left join', ['u' => User::tableName()], 'o.user_id = u.id')
|
||
->join('left join', ['os' => OrderSale::tableName()], 'os.order_id = o.id')
|
||
->leftJoin(['box' => Box::tableName()], 'o.coach_id=box.id')
|
||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||
->andWhere([
|
||
'o.user_id' => $this->user_id,
|
||
'o.is_delete' => 0,
|
||
'os.is_delete' => 0,
|
||
])->andFilterWhere(['o.id' => $this->order_id]);
|
||
|
||
|
||
$query->select('os.id,os.order_no,u.nickname,od.start_time,od.end_time,od.duration,o.total_pay_price,box.name as box_name,u.real_name,u.mobile_phone,os.created_at,os.updated_at,os.status as sale_stauts,od.goods_attr_info,s.name as store_name');
|
||
|
||
$count = $query->count();
|
||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['os.id' => SORT_DESC])->asArray()->all();
|
||
foreach ($list as $key => $value) {
|
||
|
||
$list[$key]['created_at'] = date('Y-m-d H:i:s', $value['created_at']);
|
||
$list[$key]['updated_at'] = date('Y-m-d H:i:s', $value['updated_at']);
|
||
$list[$key]['user_name'] = $value['real_name'] ? $value['real_name'] : $value['nickname'];
|
||
|
||
$list[$key]['plugin_sign_cn'] = $value['goods_attr_info'];
|
||
$list[$key]['goods_id'] = $value['box_name'];
|
||
|
||
if ($value['sale_stauts'] == 2) {
|
||
$list[$key]['state_cn'] = '已通过';
|
||
$list[$key]['state'] = '2';
|
||
} else if ($value['sale_stauts'] == 1) {
|
||
$list[$key]['state_cn'] = '待处理';
|
||
$list[$key]['state'] = '1';
|
||
} else if ($value['is_pay'] == 3) {
|
||
$list[$key]['state_cn'] = '已拒绝';
|
||
$list[$key]['state'] = '3';
|
||
}
|
||
|
||
|
||
if ($value['sale_stauts'] == 1) {
|
||
$temp_data['sale_order_no'][] = $list[$key];
|
||
} else {
|
||
$temp_data['sale_order_ok'][] = $list[$key];
|
||
}
|
||
}
|
||
|
||
if (isset($temp_data)) {
|
||
$list = [];
|
||
$list = array_merge($list, $temp_data['sale_order_no'] ?? []);
|
||
$list = array_merge($list, $temp_data['sale_order_ok'] ?? []);
|
||
// $list = array_merge($temp_data, $list);
|
||
}
|
||
|
||
|
||
$this->pageCount = $pagination->pageCount;
|
||
$end_flag = $this->page >= $pagination->pageCount ? true : false;
|
||
return [
|
||
'code' => 0,
|
||
'msg' => 'ok',
|
||
'data' => $list,
|
||
'count' => $count,
|
||
'page_size' => $this->limit,
|
||
'page_count' => $this->pageCount,
|
||
'page_no' => $this->page,
|
||
'end_flag' => $end_flag,
|
||
];
|
||
}
|
||
|
||
//校验是否需要缴纳押金
|
||
public function check_deposit()
|
||
{
|
||
|
||
if (!$this->validate()) {
|
||
return $this->getModelError();
|
||
}
|
||
|
||
$deposit_money = \Yii::$app->params['deposit_money'];
|
||
if ($this->plugin_sign == SysConst::$cxPluginSceneDeposit) {
|
||
//订单类型为缴纳押金时判断支付方式为支付分时报错
|
||
if ($this->pay_type == SysConst::$cxPayTypeWxpayPoints) {
|
||
return $this->apiReturnError('缴纳押金不能使用支付分');
|
||
}
|
||
//订单类型为缴纳押金时返回【不用缴纳】
|
||
return $this->apiReturnSuccess('ok', ['is_deposit', false, 'deposit_money' => $deposit_money]);
|
||
}
|
||
|
||
//订单类型为球车租赁且支付方式为支付分时返回【不用缴纳】
|
||
if ($this->plugin_sign == SysConst::$cxPluginSceneBallCart && $this->pay_type == SysConst::$cxPayTypeEnWxpayPoints) {
|
||
return $this->apiReturnSuccess('ok', ['is_deposit', false, 'deposit_money' => $deposit_money]);
|
||
}
|
||
|
||
//用户为门店管理员或门店服务员时不用缴纳押金
|
||
if ($this->user_type == User::TYPE_STORE) {
|
||
$is_store_user = StoreUser::find()->where(['user_id' => $this->user_id, 'store_id' => $this->store_id, 'user_type' => [1, 2], 'is_delete' => 0, 'status' => 0])->exists();
|
||
if ($is_store_user) {
|
||
return $this->apiReturnSuccess('ok', ['is_deposit', false, 'deposit_money' => $deposit_money]);
|
||
}
|
||
}
|
||
//查询未退款的押金订单是否存在
|
||
$is_order = Order::find()->where(['user_id' => $this->user_id, 'pay_type' => SysConst::$cxPayTypeWxpay, 'plugin_sign' => SysConst::$cxPluginSceneDeposit, 'is_pay' => 1, 'is_delete' => 0, 'status' => 1])->exists();
|
||
if ($is_order) {
|
||
return $this->apiReturnSuccess('ok', ['is_deposit', false, 'deposit_money' => $deposit_money]);
|
||
}
|
||
return $this->apiReturnSuccess('ok', ['is_deposit', true, 'deposit_money' => $deposit_money]);
|
||
}
|
||
|
||
//创建押金订单
|
||
public function createOrderDeposit()
|
||
{
|
||
if (!$this->validate()) {
|
||
return $this->getModelError();
|
||
}
|
||
|
||
if (empty($this->plugin_sign) || $this->plugin_sign != SysConst::$cxPluginSceneDeposit) {
|
||
return $this->apiReturnError('订单类型错误');
|
||
}
|
||
if ($this->plugin_sign == SysConst::$cxPluginSceneDeposit && $this->pay_type == SysConst::$cxPayTypeWxpayPoints) {
|
||
//订单类型为缴纳押金时判断支付方式为支付分时报错
|
||
return $this->apiReturnError('缴纳押金不能使用支付分');
|
||
}
|
||
|
||
$deposit_money = \Yii::$app->params['deposit_money'];
|
||
if ($this->price != $deposit_money) {
|
||
return $this->apiReturnError('订单金额异常');
|
||
}
|
||
|
||
try {
|
||
$t = \Yii::$app->db->beginTransaction();
|
||
|
||
//订单类型
|
||
$orderType = UniqueOrderNo::ORDER_TYPE_DEPOSIT;
|
||
$goods_info = '缴纳押金';
|
||
|
||
$order = new Order();
|
||
$order->cx_mch_id = $this->cx_mch_id;
|
||
$order->user_id = $this->user_id;
|
||
$order->order_no = UniqueOrderNo::generate($orderType, Order::class, 24, 1, 3, 'order_no');
|
||
$order->total_price = (int)$deposit_money; //总金额
|
||
$order->store_id = $this->store_id;
|
||
|
||
$order->coupon_discount_price = 0;
|
||
$order->use_user_coupon_id = 0;
|
||
$order->total_pay_price = (int)$deposit_money; //实际支付
|
||
$order->total_goods_price = (int)$deposit_money; //订单商品总金额(优惠后)
|
||
$order->total_goods_original_price = (int)$deposit_money; //订单商品总金额(优惠前)
|
||
$order->express_original_price = 0;
|
||
$order->express_price = 0;
|
||
|
||
$order->is_pay = 0;
|
||
$order->pay_type = SysConst::$cxPayTypeWxpay;
|
||
$order->plugin_sign = SysConst::$cxPluginSceneDeposit;
|
||
$order->created_at = time();
|
||
if (!$order->save()) {
|
||
$t->rollBack();
|
||
return $this->apiReturnError('创建订单错误', $this->getModelError($order));
|
||
}
|
||
|
||
$orderdetail = new OrderDetail();
|
||
$orderdetail->cx_mch_id = $this->cx_mch_id;
|
||
$orderdetail->order_id = $order->id;
|
||
$orderdetail->goods_id = $this->ball_number;
|
||
$orderdetail->num = 1;
|
||
$orderdetail->unit_price = (int)$deposit_money; //实际支付
|
||
$orderdetail->total_original_price = (int)$deposit_money;
|
||
$orderdetail->total_price = (int)$deposit_money;
|
||
$orderdetail->plugin_sign = SysConst::$cxPluginSceneDeposit;
|
||
$orderdetail->goods_attr_info = $goods_info;
|
||
$orderdetail->created_at = time();
|
||
if (!$orderdetail->save()) {
|
||
$t->rollBack();
|
||
return $this->apiReturnError('创建订单错误', $this->getModelError($orderdetail));
|
||
}
|
||
|
||
$t->commit();
|
||
return $this->apiReturnSuccess('ok', ['id' => $order->id]);
|
||
} catch (Exception $exception) {
|
||
$t->rollBack();
|
||
return [
|
||
'code' => 1,
|
||
'msg' => '创建订单失败' . $exception->getMessage(),
|
||
'data' => null
|
||
];
|
||
}
|
||
|
||
}
|
||
|
||
//押金订单列表
|
||
public function search_order_deposit()
|
||
{
|
||
|
||
$query = Order::find()->alias('o')
|
||
->select('o.id as order_id,o.is_sale,o.total_pay_price as total_price,rt.goods_id as ball_number,ball.cover_pic,
|
||
o.is_pay,o.store_id,o.plugin_sign,s.phone,o.confirm_time,o.created_at,o.updated_at,o.pay_time,o.cancel_status,o.status,s.name as store_name,o.store_id,o.is_confirm')
|
||
->groupBy('o.id')
|
||
->leftJoin(['rt' => OrderDetail::tableName()], 'o.id=rt.order_id')
|
||
->leftJoin(['ball' => BallCart::tableName()], 'rt.goods_id=ball.ball_number')
|
||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||
->where([
|
||
'o.is_delete' => 0,
|
||
'rt.is_delete' => 0,
|
||
'ball.is_delete' => 0,
|
||
's.is_delete' => 0,
|
||
'o.user_id' => $this->user_id,
|
||
'o.is_pay' => $this->is_pay,
|
||
'plugin_sign' => SysConst::$cxPluginSceneDeposit
|
||
]);
|
||
|
||
$count = $query->count();
|
||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit, 'page' => $this->page - 1]);
|
||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['ball.id' => SORT_DESC])->asArray()->all();
|
||
foreach ($list as $index => &$item) {
|
||
if ($item['status'] == 0) {
|
||
$order_status = 0; //球车订单已关闭。押金订单已触发还车按钮
|
||
if ($item['is_confirm'] == 0) { //判断退款
|
||
$deposit_title = '待退款'; //未发起
|
||
} elseif ($item['is_confirm'] == 1) {
|
||
$deposit_title = '退款成功';
|
||
} elseif ($item['is_confirm'] == 2) {
|
||
$deposit_title = '退款关闭';
|
||
} elseif ($item['is_confirm'] == 3) {
|
||
$deposit_title = '退款异常';
|
||
}
|
||
} elseif ($item['is_pay'] == 1) {
|
||
$order_status = 1; //已支付
|
||
}
|
||
|
||
$item['order_status'] = $order_status;
|
||
$item['deposit_title'] = $deposit_title;
|
||
$item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
|
||
$item['updated_at'] = date('Y-m-d H:i:s', $item['updated_at']);
|
||
}
|
||
$end_flag = $this->page >= $pagination->pageCount ? true : false;
|
||
return [
|
||
'code' => 0,
|
||
'msg' => 'ok',
|
||
'data' => $list,
|
||
'count' => $count,
|
||
'page_size' => $this->limit,
|
||
'page_count' => $pagination->pageCount,
|
||
'page_no' => $this->page,
|
||
'end_flag' => $end_flag
|
||
];
|
||
}
|
||
|
||
//生成支付分订单
|
||
public function createOrderPoints($order_no, $amount, $ball_number)
|
||
{
|
||
try {
|
||
|
||
$url = \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/notify/payment/wxpay-points';
|
||
|
||
|
||
$time = time();
|
||
$start_time = date('YmdHis', $time);
|
||
|
||
$param = [
|
||
'out_order_no' => $order_no,//商户系统内部服务订单号
|
||
'service_id' => 'service_id',//服务ID
|
||
'service_introduction' => '球车租赁',//用于介绍本订单所提供的服务 ,当参数长度超过20个字符时,报错处理。示例值:某某酒店
|
||
'time_range' => [
|
||
'start_time' => $start_time,//服务开始时间
|
||
],
|
||
'risk_fund' => [
|
||
'name' => 'ESTIMATE_ORDER_COST',//风险金名称ESTIMATE_ORDER_COST预估订单费用
|
||
'amount' => $amount,//风险金额
|
||
'description' => '球车编号为' . $ball_number . '的租赁费用',//风险说明
|
||
],
|
||
'notify_url' => $url,//商户接收用户确认订单和付款成功回调通知的地址。
|
||
];
|
||
|
||
$plugin = new PluginService();
|
||
$wxmpService = $plugin->getWxmpService(0);
|
||
$res = $wxmpService->pay->serviceOrder($param, time());
|
||
|
||
|
||
} catch (\Exception $e) {
|
||
return $this->apiReturnError($e->getMessage());
|
||
}
|
||
|
||
}
|
||
|
||
//关闭订单-微信支付订单
|
||
public function closeOrder($order_id)
|
||
{
|
||
if (empty($order_id)) {
|
||
return $this->apiReturnError('参数异常');
|
||
}
|
||
$user_id = \Yii::$app->user->identity->id;
|
||
$paymentOrderUnion = PaymentOrderUnion::findOne(['id' => $order_id, 'user_id' => $user_id, 'is_pay' => 0]);
|
||
if ($paymentOrderUnion == null) {
|
||
return $this->apiReturnError('订单无效');
|
||
}
|
||
|
||
$paymentOrder = PaymentOrder::findOne(['payment_order_union_id' => $paymentOrderUnion->id]);
|
||
if ($paymentOrder == null) {
|
||
return $this->apiReturnError('订单无效');
|
||
}
|
||
|
||
$order = Order::find()->alias('o')
|
||
->select('o.id,od.goods_id')
|
||
->leftJoin(['od' => OrderDetail::tableName()], 'o.id=od.order_id')
|
||
->where(['o.order_no' => $paymentOrder->order_no, 'o.is_pay' => 0])
|
||
->asArray()
|
||
->one();
|
||
if (empty($order)) {
|
||
return $this->apiReturnError('订单无效');
|
||
}
|
||
|
||
$ball_cart = BallCart::find()->where(['ball_number' => $order['goods_id'], 'is_delete' => 0, 'status' => 3])->orderBy(['id' => SORT_DESC])->one();
|
||
if ($ball_cart == null) {
|
||
return $this->apiReturnSuccess('订单无需变更');
|
||
}
|
||
$ball_cart->status = 0;
|
||
$ball_cart->updated_at = time();
|
||
if (!$ball_cart->save()) {
|
||
return $this->getModelError($ball_cart);
|
||
}
|
||
return $this->apiReturnSuccess('ok');
|
||
}
|
||
|
||
|
||
/**
|
||
* 小兔开门 type =1 点击开门 2 二维码开门
|
||
*/
|
||
public function openDoor()
|
||
{
|
||
if (empty($this->order_id)) {
|
||
return $this->apiReturnError('错误订单');
|
||
}
|
||
|
||
if (empty($this->open_type)) {
|
||
return $this->apiReturnError('错误类型');
|
||
}
|
||
|
||
if ($this->open_type == 2) {
|
||
if (empty($this->end_time)) {
|
||
return $this->apiReturnError('结束时间不能为空');
|
||
}
|
||
}
|
||
|
||
if (empty($this->sn)) {
|
||
return $this->apiReturnError('错误:sn');
|
||
}
|
||
|
||
$order = Order::find()
|
||
->select('id')
|
||
->where(['is_pay' => 1, 'id' => $this->order_id, 'user_id' => $this->user_id, 'plugin_sign' => 'box_book',])
|
||
->asArray()
|
||
->one();
|
||
if (empty($order)) {
|
||
return $this->apiReturnError('订单无效');
|
||
}
|
||
$find_order_detial = OrderDetail::findOne([
|
||
'order_id' => $order['id'],
|
||
]);
|
||
if (empty($find_order_detial)) {
|
||
return $this->apiReturnError('订单无效');
|
||
}
|
||
if ($find_order_detial->start_at - 60 * 15 > time()) {
|
||
return $this->apiReturnError('订单未开始');
|
||
}
|
||
if ($find_order_detial->end_at < time()) {
|
||
return $this->apiReturnError('订单已结束');
|
||
}
|
||
|
||
$xtOpenApi = new XtOpenApi();
|
||
|
||
$xtOpenApi->user_id = $this->user_id;
|
||
if ($this->open_type == 1) {
|
||
return $xtOpenApi->Open($this->sn);
|
||
}
|
||
|
||
if ($this->open_type == 2) {
|
||
return $xtOpenApi->OpenQr($this->sn, $this->end_time);
|
||
}
|
||
|
||
}
|
||
|
||
public function searchAll()
|
||
{
|
||
|
||
$field = 'o.id as order_id,o.is_sale,o.total_price,o.is_pay,o.store_id,o.plugin_sign,s.store_mobile,o.created_at,o.updated_at,o.pay_time,o.integral,o.cancel_status,o.status,s.name as store_name,o.store_id,o.total_pay_price,s.city,s.region,o.member_discount,s.location_detail,s.cover_pic,b.money as box_money,o.total_goods_price,b.name as box_name,o.cancel_status,b.cover_pic as box_pic,b.sn';
|
||
|
||
$query = Order::find()->alias('o')
|
||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||
->leftJoin(['b' => Box::tableName()], 'b.id=o.coach_id')
|
||
->select($field)
|
||
->where([
|
||
'o.is_delete' => 0,
|
||
'o.user_id' => $this->user_id,
|
||
]);
|
||
if ($this->status == 1) {
|
||
$query->andWhere(['o.status' => 1, 'o.is_pay' => 0]);
|
||
} elseif ($this->status == 2) {
|
||
$query->andWhere(['o.is_pay' => 1, 'o.status' => [0, 1]]);
|
||
} elseif ($this->status == 3) {
|
||
$query->andWhere(['o.status' => [2, 3]]);
|
||
}
|
||
|
||
$count = $query->count();
|
||
$pagination = new Pagination(['pageSize' => $this->limit, 'totalCount' => $count, 'page' => $this->page - 1]);
|
||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.id' => SORT_DESC])->asArray()->all();
|
||
$end_flag = $this->page > $pagination->pageCount ? true : false;
|
||
$orderSalesTime = SiteHelper::getCustomiseOptionByKey("orderSalesTime", "hump"); //可申请售后时间
|
||
$orderTimeoutCancel = SiteHelper::getCustomiseOptionByKey("orderTimeoutCancel", "hump"); //订单取消周期
|
||
$orderTimeoutCancel = $orderTimeoutCancel * 60;
|
||
|
||
foreach ($list as $index => &$item) {
|
||
|
||
if ($item['plugin_sign'] == SysConst::$cxPluginSceneGoods) {
|
||
$item['id'] = $item['order_id'];
|
||
$item['created_at_cn'] = date('Y/m/d H:i', $item['created_at']);
|
||
$item['total_goods_price'] = sprintf("%.2f", $item['total_goods_price']);
|
||
$item['total_price'] = sprintf("%.2f", $item['total_price']);
|
||
|
||
$detail = OrderDetail::find()
|
||
->where(['is_delete' => 0, 'plugin_sign' => 'goods', 'order_id' => $item['id']])
|
||
->select('id,goods_attr_info')->asArray()->all();
|
||
$item['count'] = count($detail);
|
||
foreach ($detail as $index2 => &$item2) {
|
||
$item2['goods_attr_info'] = json_decode($item2['goods_attr_info'], true);
|
||
}
|
||
$goods_attr_infos = array_column($detail, 'goods_attr_info');
|
||
$cover_pics = array_column($goods_attr_infos, 'cover_pic');
|
||
$item['cover_pics'] = array_filter($cover_pics);
|
||
|
||
switch ($item['status']) {
|
||
case 0:
|
||
$item['status_cn'] = '已完成';
|
||
break;
|
||
case 1:
|
||
$item['status_cn'] = '待支付';
|
||
break;
|
||
case 2:
|
||
$item['status_cn'] = '已完成';
|
||
break;
|
||
case 3:
|
||
$item['status_cn'] = '已取消';
|
||
break;
|
||
default:
|
||
$item['status_cn'] = '未知';
|
||
}
|
||
|
||
$item['sale_button'] = false;
|
||
$time = $item['pay_time'] + ($orderSalesTime * 60);
|
||
if ($time > time() && $item['total_goods_price'] > 0 && $item['status'] == 0) {
|
||
$item['sale_button'] = true;
|
||
}
|
||
|
||
} else {
|
||
$field2 = 'goods_id,start_time,end_time,duration,start_at,end_at';
|
||
$detail = OrderDetail::find()->select($field2)->where(['is_delete' => 0, 'order_id' => $item['order_id']])->asArray()->one();
|
||
$item['goods_id'] = $detail['goods_id'];
|
||
$item['start_time'] = $detail['start_time'];
|
||
$item['end_time'] = $detail['end_time'];
|
||
$item['duration'] = $detail['duration'];
|
||
$item['start_at'] = $detail['start_at'];
|
||
$item['end_at'] = $detail['end_at'];
|
||
$timeout_cancel = floor(($item['created_at'] + $orderTimeoutCancel) - time());
|
||
$timeout_cancel = $timeout_cancel <= 0 || $item['is_pay'] == 1 || $item['status'] != 1 ? 0 : $timeout_cancel;
|
||
$item['timeout_cancel'] = $timeout_cancel;
|
||
|
||
$item['sale_button'] = false;
|
||
$time = $item['pay_time'] + ($orderSalesTime * 60);
|
||
if ($time > time() && $item['total_goods_price'] > 0 && $item['status'] == 0) {
|
||
$item['sale_button'] = true;
|
||
}
|
||
|
||
$sn = $item['sn'];
|
||
unset($item['sn']);
|
||
|
||
$item['box_pic'] = SiteHelper::getFullUrl($item['box_pic']);
|
||
//status 订单状态:0=已完成 1=进行中,2-用户申请售后 3-用户取消(超时未支付) 4-订单过期(支付未使用)
|
||
//cancel_status 订单取消状态:0=未取消,1=已取消,2=申请取消
|
||
//is_pay 0=未支付,1=已支付
|
||
|
||
$item['status_cn'] = '已完成';
|
||
|
||
|
||
$item['cover_pic'] = substr($item['cover_pic'], 0, 7) == 'http://' ?$item['cover_pic'] : SiteHelper::getFullUrl($item['cover_pic']);
|
||
// $item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
||
|
||
|
||
|
||
$item['box_pic'] = SiteHelper::getFullUrl($item['box_pic']);
|
||
$item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
|
||
$item['updated_at'] = date('Y-m-d H:i:s', $item['updated_at']);
|
||
$item['total_goods_price'] = sprintf("%.2f", $item['total_goods_price']);
|
||
$item['total_price'] = sprintf("%.2f", $item['total_price']);
|
||
if ($item['is_pay'] == 1) {
|
||
$item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
|
||
}
|
||
|
||
//待支付 status = 1 is_pay = 0
|
||
if ($item['status'] == self::ORDER_ING && $item['is_pay'] == self::ORDER_OK && $item['cancel_status'] == self::ORDER_OK && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$item['status_cn'] = '待支付';
|
||
}
|
||
|
||
|
||
//已支付 进行中 status = 1 is_pay = 1
|
||
if ($item['status'] == self::ORDER_ING && $item['is_pay'] == self::ORDER_ING && $item['cancel_status'] == self::ORDER_OK && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
|
||
$item['status_cn'] = '已预约';
|
||
$item['rabbit_sn'] = $sn;
|
||
if ($item['start_at'] - 60 * 15 < time() && $item['end_at'] > time()) {
|
||
$item['status_cn'] = '查看二维码';
|
||
}
|
||
}
|
||
|
||
//已完成 status = 0 is_pay = 1 cancel_status = 0
|
||
if ($item['status'] == self::ORDER_OK && $item['is_pay'] == self::PAY_OK && $item['cancel_status'] == self::ORDER_OK && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$item['status_cn'] = '已完成';
|
||
}
|
||
|
||
//用户申请售后 status=2 is_sale = 0
|
||
if ($item['status'] == self::ORDER_PAY_ING && $item['is_sale'] == self::PAY_NO && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$item['status_cn'] = '售后中';
|
||
}
|
||
|
||
//订单已售后 status=0 is_sale=1
|
||
if ($item['status'] == self::ORDER_OK && $item['is_sale'] == self::PAY_OK && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$item['status_cn'] = '已售后';
|
||
}
|
||
|
||
//订单已取消 status = 3 is_pay = 0 超时未支付 cancel_status = 1
|
||
if ($item['status'] == 3 && $item['is_pay'] == self::ORDER_OK && $item['cancel_status'] == 1 && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$item['status_cn'] = '已取消';
|
||
}
|
||
|
||
//订单已过期 status = 4 is_pay = 1
|
||
if ($item['status'] == 4 && $item['is_pay'] == self::ORDER_ING && $item['plugin_sign'] == SysConst::$cxPluginSceneBallCart) {
|
||
$item['status_cn'] = '已过期';
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
return [
|
||
'code' => 0,
|
||
'msg' => 'ok',
|
||
'data' => $list,
|
||
'count' => $count,
|
||
'page' => $this->page,
|
||
'limit' => $this->limit,
|
||
'page_count' => $pagination->pageCount,
|
||
'end_flag' => $end_flag,
|
||
];
|
||
}
|
||
|
||
|
||
public function actionGetBoxOrder()
|
||
{
|
||
|
||
}
|
||
|
||
} |