初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\order;
|
||||
|
||||
use think\Model;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\constant\order\Status as OrderStatusConstant;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
class Status extends Model
|
||||
{
|
||||
public function getControllTypes(){
|
||||
return [
|
||||
// 'delete'=>false,
|
||||
'evaluate'=>false,
|
||||
'cancel'=>false,
|
||||
'pay'=>false,
|
||||
'service'=>false,
|
||||
'surereceive'=>false,
|
||||
'express'=>false,
|
||||
];
|
||||
}
|
||||
|
||||
protected $controllTypes = [
|
||||
// 'delete',
|
||||
'evaluate','cancel','pay','service','surereceive','express',
|
||||
];
|
||||
|
||||
/**
|
||||
* 根据状态获取查询条件
|
||||
* @param $status
|
||||
* @return void
|
||||
*/
|
||||
public static function statusGetFilter($status){
|
||||
$filter = [];
|
||||
if($status == 'unevaluate'){
|
||||
$filter['status'] = OrderStatusConstant::STATUS_SUCCESS;
|
||||
$filter['evaluate'] = 0;
|
||||
}elseif($status == 'service'){
|
||||
// $filter['service'] = ['<>',0];
|
||||
$filter['status'] = OrderStatusConstant::STATUS_REFUND;
|
||||
}else{
|
||||
if(!empty($status)){
|
||||
$filter['status'] = $status;
|
||||
}
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单是否可以评价
|
||||
* @param $orderInfo
|
||||
* @return bool
|
||||
*/
|
||||
public function getOrderIsEvaluate($orderInfo){
|
||||
if(!empty($orderInfo['item'])){
|
||||
foreach ($orderInfo['item'] as $item){
|
||||
if($item['evaluate']==0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单可进行的操作
|
||||
* @param $orderInfo
|
||||
* @return false[]
|
||||
*/
|
||||
public function getOrderControllStatus($orderInfo){
|
||||
|
||||
$controllTypes = $this->getControllTypes();
|
||||
|
||||
foreach ($controllTypes as $key => $value){
|
||||
switch ($key) {
|
||||
case 'evaluate': //评价
|
||||
if ($orderInfo['status'] == \app\common\constant\order\Status::STATUS_SUCCESS && $orderInfo['evaluate'] == 0) {
|
||||
$controllTypes[$key] = true;
|
||||
}
|
||||
break;
|
||||
case 'cancel': //取消订单
|
||||
if ($orderInfo['status'] == 'unpaid') {
|
||||
$controllTypes[$key] = $key;
|
||||
}
|
||||
break;
|
||||
case 'express': //物流
|
||||
if ($orderInfo['order_type'] == "physical") {
|
||||
$controllTypes[$key] = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'surereceive': //确认收货
|
||||
if ($orderInfo['order_type'] == "physical" && $orderInfo['status'] == \app\common\constant\order\Status::STATUS_UNRECEIVE) {
|
||||
$controllTypes[$key] = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pay': //支付订单
|
||||
|
||||
//禁止iOS微信支付
|
||||
if (\app\common\library\Platform::getPlatform() == 'wxMiniProgram' && \app\common\library\Platform::getDeviceEnd() == 'ios'){
|
||||
$wxMiniProgramConfig = \app\common\model\config\System::getConfig('wxMiniProgram');
|
||||
if ($wxMiniProgramConfig['ban_pay'] == 'open') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($orderInfo['status'] == \app\common\constant\order\Status::STATUS_UNPAID){
|
||||
$controllTypes[$key] = true;
|
||||
}
|
||||
break;
|
||||
// case 'delete': //删除订单
|
||||
// if($orderInfo['status'] != \app\common\constant\order\Status::STATUS_SERVICE){
|
||||
// $controllTypes[$key] = true;
|
||||
// }
|
||||
// break;
|
||||
case 'service': //售后服务
|
||||
|
||||
// if(!in_array($orderInfo['status'],[\app\common\constant\order\Status::STATUS_UNPAID,\app\common\constant\order\Status::STATUS_CANCEL])){
|
||||
// $controllTypes[$key] = true;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $controllTypes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user