Browse Source

Merge branch 'yijia' of http://47.101.187.29:8081/loumengning/shop into yijia

undefined
xubinxcode 4 years ago
parent
commit
3e136165c0
2 changed files with 38 additions and 24 deletions
  1. +31
    -17
      addons/unishop/controller/Order.php
  2. +7
    -7
      public/assets/js/backend/unishop/order.js

+ 31
- 17
addons/unishop/controller/Order.php View File

@@ -226,13 +226,23 @@ class Order extends Base
if ($order['have_paid'] != \addons\unishop\model\Order::PAID_NO) {
$this->error('此订单已支付,无法取消');
}
$redis = new Redis();
$flash = (new \addons\unishop\model\Order)->alias("o")->
join("unishop_order_product","unishop_order_product.order_id =o.id")
->where(["o.id"=>(int)$order_id])
->field("flash_id,product_id")->find();
if ($flash){
$redis->handler->hIncrBy('flash_sale_' . $flash->flash_id. '_' . $flash->product_id, 'sold', -1);
// $redis = new Redis();
// $flash = (new \addons\unishop\model\Order)->alias("o")->
// join("unishop_order_product","unishop_order_product.order_id =o.id")
// ->where(["o.id"=>(int)$order_id])
// ->field("flash_id,product_id")->find();
// if ($flash){
// $redis->handler->hIncrBy('flash_sale_' . $flash->flash_id. '_' . $flash->product_id, 'sold', -1);
// }
$orderProduct = new OrderProduct();

$list =$orderProduct->where([
'order_id' => $order_id
])->select();
$list = collection($list)->toArray();
$product = new \app\admin\model\unishop\Product();
foreach ($list as $val){
$product->where(["id"=>$val['product_id']])->setInc("stock",$val["number"]);
}

if ($order['status'] == \addons\unishop\model\Order::STATUS_NORMAL && $order['have_paid'] == \addons\unishop\model\Order::PAID_NO) {
@@ -598,6 +608,8 @@ class Order extends Base
}

public function doRefund(){
$this->error("暂不支持");

$order_id = $this->request->post('order_id');
$order_id = Hashids::decodeHex($order_id);
$orderModel = new \addons\unishop\model\Order();
@@ -612,16 +624,16 @@ class Order extends Base
if (!$order){
$this->error("订单信息错误");
}
$redis = new Redis();
$flash = $orderModel->alias("o")->
join("unishop_order_product","unishop_order_product.order_id =o.id")
->join("unishop_flash_sale","unishop_order_product.flash_id=unishop_flash_sale.id")
->where(["o.id"=>(int)$order_id,"unishop_flash_sale.status"=>0,"unishop_flash_sale.switch"=>1,"unishop_flash_sale.deletetime"=>0])
->field("flash_id,product_id,endtime")->find();
if (!$flash || $flash->endtime < time()){
$this->error("活动已结束,不支持退款");
}
$sold = $redis->handler->hIncrBy('flash_sale_' . $flash->flash_id. '_' . $flash->product_id, 'sold', -1);
// $redis = new Redis();
// $flash = $orderModel->alias("o")->
// join("unishop_order_product","unishop_order_product.order_id =o.id")
// ->join("unishop_flash_sale","unishop_order_product.flash_id=unishop_flash_sale.id")
// ->where(["o.id"=>(int)$order_id,"unishop_flash_sale.status"=>0,"unishop_flash_sale.switch"=>1,"unishop_flash_sale.deletetime"=>0])
// ->field("flash_id,product_id,endtime")->find();
// if (!$flash || $flash->endtime < time()){
// $this->error("活动已结束,不支持退款");
// }
// $sold = $redis->handler->hIncrBy('flash_sale_' . $flash->flash_id. '_' . $flash->product_id, 'sold', -1);
$order->status = \addons\unishop\model\Order::STATUS_REFUND;
$order->refund_status = \addons\unishop\model\Order::REFUND_STATUS_AGREE;
$result = $order->save();
@@ -636,6 +648,8 @@ class Order extends Base
PayService::cancel($param,$order["pay_type"]);
$this->success("success",[]);
}


$this->error("订单信息错误");
}



+ 7
- 7
public/assets/js/backend/unishop/order.js View File

@@ -140,13 +140,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// extend: 'data-toggle="tooltip"',
// icon: 'fa fa-plane'
// },
// {
// name: 'product',
// text: __('Product'),
// classname: 'btn btn-xs btn-info btn-product',
// extend: 'data-toggle="tooltip"',
// icon: 'fa fa-star-half'
// },
{
name: 'product',
text: __('Product'),
classname: 'btn btn-xs btn-info btn-product',
extend: 'data-toggle="tooltip"',
icon: 'fa fa-star-half'
},
{
name: 'edit',
icon: 'fa fa-pencil',


Loading…
Cancel
Save