setter
parent
aa59dd10ae
commit
d8abca7acb
|
@ -321,7 +321,7 @@ class Order extends Base
|
|||
$reason = $this->request->param('remarks', '');
|
||||
|
||||
try {
|
||||
OrderRepository::getInstance()->setClosed($orderCoding, OrderModel::STATUS_CLOSED, $reason);
|
||||
OrderRepository::getInstance()->setClosed($orderCoding, OrderModel::STATUS_CANCEL, $reason);
|
||||
} catch (RepositoryException $e) {
|
||||
return $this->json(4000, $e->getMessage());
|
||||
}
|
||||
|
@ -472,4 +472,6 @@ class Order extends Base
|
|||
return $this->json(0, "success", ["path" => resourceJoin($savePath, $this->request->domain()), "content" => $content]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1057,6 +1057,7 @@ class User extends Base
|
|||
$domain = $this->request->domain();
|
||||
|
||||
$res = OrderRepository::getInstance()->detail($id);
|
||||
$res["status_text"] = OrderRepository::getInstance()->orderStatusTextList()[$res["status"]];
|
||||
$res->skus->each(function ($sku) use ($domain) {
|
||||
$specArr = json_decode($sku->spec_text, true);
|
||||
$sku->spec_text = $specArr;
|
||||
|
|
|
@ -938,9 +938,12 @@ class OrderRepository extends Repository
|
|||
'accepted_at' => $nowDateTime
|
||||
], ['id' => $orderId]);
|
||||
|
||||
/*
|
||||
CConfig::load('extra/commission_withdrawal', 'commission');
|
||||
$config = config('commission');
|
||||
*/
|
||||
// 一级佣金发放
|
||||
/*
|
||||
if ($account['inviter_account_id'] > 0 && isset($config['commission_first']) && $config['commission_first'] > 0) {
|
||||
$firstRate = Math::div($config['commission_first'], 100);
|
||||
$firstCommission = Math::mul($order['price'], $firstRate);
|
||||
|
@ -958,8 +961,10 @@ class OrderRepository extends Repository
|
|||
]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// 二级分销发放佣金
|
||||
/*
|
||||
if ($account['inviter_parent_id'] > 0 && isset($config['commission_second']) && $config['commission_second'] > 0) {
|
||||
$secondRate = Math::div($config['commission_second'], 100);
|
||||
$secondCommission = Math::mul($order['price'], $secondRate);
|
||||
|
@ -977,6 +982,7 @@ class OrderRepository extends Repository
|
|||
]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Db::commit();
|
||||
} catch (RepositoryException $e) {
|
||||
|
@ -1006,37 +1012,48 @@ class OrderRepository extends Repository
|
|||
$where[] = ['account_id', '=', $accountId];
|
||||
event('OrderCheck');
|
||||
|
||||
|
||||
switch ($tag) {
|
||||
//待付款 已付款 已过期 待发货 待收货
|
||||
case self::STATUS_WAITING:
|
||||
case self::STATUS_PAID:
|
||||
// case self::STATUS_EXPIRED:
|
||||
case self::STATUS_ORDER_PLACED:
|
||||
case self::STATUS_MAKEING:
|
||||
case self::STATUS_SHIPPED:
|
||||
case self::STATUS_ARRIVED:
|
||||
case self::STATUS_COMPLETED:
|
||||
case self::STATUS_CLOSED:
|
||||
case self::STATUS_CANCEL:
|
||||
$status = [$tag];
|
||||
break;
|
||||
// 待评价 已确认收货 未评价
|
||||
/*
|
||||
case 'waiting_comment':
|
||||
$where[] = ['is_evaluate', '=', self::IS_EVALUATE_YES];
|
||||
$status = [self::STATUS_COMPLETED];
|
||||
break;
|
||||
*/
|
||||
// 待核验
|
||||
/*
|
||||
case 'check':
|
||||
$where[] = ['has_virtual', '=', Order::COMMON_ON];
|
||||
$where[] = ['virtual_check', '=', Order::COMMON_OFF];
|
||||
$where[] = ['frontend_check', '=', Order::COMMON_OFF];
|
||||
$status = [self::STATUS_PAID, self::STATUS_COMPLETED, self::STATUS_SHIPPED];
|
||||
break;
|
||||
*/
|
||||
// 售后记录
|
||||
/*
|
||||
case 'after_sale':
|
||||
$status = [self::STATUS_PAID, self::STATUS_SHIPPED, self::STATUS_COMPLETED];
|
||||
$where[] = ['is_after_sale', '=', self::BOOL_TRUE];
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
$status = [
|
||||
self::STATUS_WAITING, self::STATUS_PAID, self::STATUS_COMPLETED,
|
||||
self::STATUS_SHIPPED, self::STATUS_CLOSED
|
||||
self::STATUS_ORDER_PLACED ,
|
||||
self::STATUS_MAKEING ,
|
||||
self::STATUS_SHIPPED ,
|
||||
self::STATUS_ARRIVED ,
|
||||
self::STATUS_COMPLETED ,
|
||||
self::STATUS_CANCEL ,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1374,13 +1391,13 @@ class OrderRepository extends Repository
|
|||
* @throws ModelNotFoundException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public function setClosed(string $orderCoding, string $status = Order::STATUS_CLOSED, string $reason = ''): bool
|
||||
public function setClosed(string $orderCoding, string $status = Order::STATUS_CANCEL, string $reason = ''): bool
|
||||
{
|
||||
if (!$order = Order::findOne(['coding' => $orderCoding])) {
|
||||
throw new RepositoryException('订单不存在');
|
||||
}
|
||||
|
||||
if (!in_array($order['status'], [Order::STATUS_WAITING, Order::STATUS_PAID])) {
|
||||
if (!in_array($order['status'], [Order::STATUS_ORDER_PLACED])) {
|
||||
throw new RepositoryException('订单状态不允许此操作');
|
||||
}
|
||||
|
||||
|
@ -1395,35 +1412,38 @@ class OrderRepository extends Repository
|
|||
// 活动订单取消
|
||||
OrderActivity::cancel($orderCoding);
|
||||
|
||||
$account = Account::findById($order['account_id']);
|
||||
//$account = Account::findById($order['account_id']);
|
||||
$order->close_reason = $reason;
|
||||
//待付款订单
|
||||
if ($order['status'] == Order::STATUS_WAITING) {
|
||||
// if ($order['status'] == Order::STATUS_ORDER_PLACED) {
|
||||
$order->status = $status;
|
||||
$order->save();
|
||||
//积分日志
|
||||
|
||||
/*
|
||||
if ($order['score'] > 0) {
|
||||
AccountDataLog::log($order['account_id'], '取消订单退回', $order['score'], AccountDataLog::TYPE_SCORE,
|
||||
AccountDataLog::ACTION_ORDER, $account['score'] + $order['score']);
|
||||
}
|
||||
|
||||
*/
|
||||
//待付款时 积分才退回
|
||||
/*
|
||||
$account->save([
|
||||
'score' => Db::raw('`score` + '.$order['score'])
|
||||
]);
|
||||
*/
|
||||
|
||||
// 优惠券退回
|
||||
/*
|
||||
AccountCoupon::where('order_coding', $orderCoding)->where('account_id', $order['account_id'])
|
||||
->where('coupon_id', $order['coupon_id'])
|
||||
->where('status', AccountCoupon::STATUS_USED)
|
||||
->update(['status' => AccountCoupon::STATUS_NORMAL]);
|
||||
|
||||
*/
|
||||
Db::commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($order['status'] == Order::STATUS_PAID && $status == Order::STATUS_CLOSED) {
|
||||
//}
|
||||
/*
|
||||
if ($order['status'] == Order::STATUS_PAID && $status == Order::STATUS_CANCEL) {
|
||||
//已付款订单 取消
|
||||
//若已有虚拟商品被核销 则订单不允许退回 积分不退回
|
||||
// $hasCheckSku = OrderSku::where('coding', $orderCoding)
|
||||
|
@ -1481,6 +1501,7 @@ class OrderRepository extends Repository
|
|||
Db::commit();
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
} catch (RepositoryException $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
|
|
|
@ -14,16 +14,18 @@ class Order
|
|||
{
|
||||
Log::info('触发订单检测事件:自动收货、自动过期');
|
||||
$day = 3;//自动收货时间 发货后N天
|
||||
$expiredList = OrderRepository::getInstance()->expiredList();
|
||||
// $expiredList = OrderRepository::getInstance()->expiredList();
|
||||
$needAcceptList = OrderRepository::getInstance()->autoReceiptList($day);
|
||||
// var_dump($expiredList->isEmpty());
|
||||
// var_dump($needAcceptList->isEmpty());
|
||||
// exit;
|
||||
/*
|
||||
if (!$expiredList->isEmpty()) {
|
||||
OrderModel::whereIn('id', $expiredList->column('id'))->save([
|
||||
'status' => OrderModel::STATUS_EXPIRED,
|
||||
]);
|
||||
}
|
||||
*/
|
||||
|
||||
if (!$needAcceptList->isEmpty()) {
|
||||
// OrderModel::whereIn('id', $needAcceptList->column('id'))->save([
|
||||
|
|
Loading…
Reference in New Issue