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