Browse Source

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

undefined
xubin 4 years ago
parent
commit
21101f7b3f
4 changed files with 82 additions and 18 deletions
  1. +9
    -0
      addons/unishop/controller/Order.php
  2. +3
    -3
      addons/unishop/model/Order.php
  3. +52
    -1
      application/admin/controller/unishop/Order.php
  4. +18
    -14
      public/assets/js/backend/unishop/order.js

+ 9
- 0
addons/unishop/controller/Order.php View File

@@ -12,6 +12,7 @@ namespace addons\unishop\controller;
use addons\nzf\AliPay;
use addons\nzf\PayService;
use addons\unishop\extend\Hashids;
use addons\unishop\extend\Redis;
use addons\unishop\model\Area;
use addons\unishop\model\Config;
use addons\unishop\model\Evaluate;
@@ -221,6 +222,14 @@ 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);
}

if ($order['status'] == \addons\unishop\model\Order::STATUS_NORMAL && $order['have_paid'] == \addons\unishop\model\Order::PAID_NO) {
$order->status = \addons\unishop\model\Order::STATUS_CANCEL;


+ 3
- 3
addons/unishop/model/Order.php View File

@@ -339,9 +339,9 @@ class Order extends Model
$orderBy = 'have_received';
break;
case self::TYPE_REFUND:
$condition['have_paid'] = ['>', self::PAID_NO];
$condition['status'] = ['=', self::STATUS_REFUND];
$condition['refund_status'] = ['<>', self::REFUND_STATUS_AGREE];
// $condition['have_paid'] = ['>', self::PAID_NO];
$condition['status'] = ['in', [self::STATUS_REFUND,self::STATUS_CANCEL]];
// $condition['refund_status'] = ['<>', self::REFUND_STATUS_AGREE];
$orderBy = 'createtime';
break;
default: //全部


+ 52
- 1
application/admin/controller/unishop/Order.php View File

@@ -2,6 +2,9 @@

namespace app\admin\controller\unishop;

use addons\nzf\PayService;
use addons\unishop\extend\Hashids;
use addons\unishop\extend\Redis;
use app\admin\model\unishop\Area;
use app\admin\model\unishop\OrderRefund;
use app\common\controller\Backend;
@@ -527,7 +530,7 @@ class Order extends Backend
GROUP_CONCAT(unishop_order_product.title) as title,
o.total_price,
SUM(unishop_order_product.number) as number,
FROM_UNIXTIME(o.createtime,\'%Y-%m-%d %H:%i:%S\')
FROM_UNIXTIME(o.createtime,\'%Y-%m-%d %H:%i:%S\'),
o.remark')
->group("o.id")
->select();
@@ -627,4 +630,52 @@ class Order extends Backend
$this->success("提交成功", null);

}

public function doRefund(){
$order_id = $this->request->get('id');
$order = $this->model->where([
'id' => (int)$order_id,
'status'=>1,//订单状态正常
// 'have_paid'=>[">",0],//已支付
// 'had_refund'=>0
])->find();
if (!$order){
$this->error("订单已取消,请勿重复操作");
}
if ($order->have_paid>0){
//已支付
self::refundOrder($order);
}else{
$order->status = \addons\unishop\model\Order::STATUS_CANCEL;
$order->save();
}
// //回退虚拟活动库存
$redis = new Redis();
$flash = $this->model->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();

$sold = $redis->handler->hIncrBy('flash_sale_' . $flash->flash_id. '_' . $flash->product_id, 'sold', -1);

$this->success("提交成功", null);

}

static function refundOrder($order){
$order->status = \addons\unishop\model\Order::STATUS_REFUND;
$order->refund_status = \addons\unishop\model\Order::REFUND_STATUS_AGREE;
$result = $order->save();
if ($result !== false){
//order_id:订单ID name:订单名称 total_fee:总金额-元 refund_fee退款金额
$param = [
"order_id"=>$order['out_trade_no'],
"total_fee"=>$order['total_price'],
"refund_fee"=>$order['total_price'],
"memo"=>'订单退款',
];
PayService::cancel($param,$order["pay_type"]);
return;
}
}
}

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

@@ -121,13 +121,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
// {
// name: 'refund',
// text: __('Refund'),
// classname: 'btn btn-xs btn-info btn-refund',
// extend: 'data-toggle="tooltip"',
// icon: 'fa fa-handshake-o'
// },
{
name: 'refund',
text: __('Refund'),
classname: 'btn btn-xs btn-info btn-ajax',
extend: 'data-toggle="tooltip"',
icon: 'fa fa-handshake-o',
url:function(row){
return "unishop/order/doRefund?id="+row.id;
},
confirm:"是否确认退款"
},
// {
// name: 'delivere',
// text: __('Delivere'),
@@ -135,13 +139,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