diff --git a/service/Application/Admin/Controller/OrderController.class.php b/service/Application/Admin/Controller/OrderController.class.php
index 2e67b5b7e..a1409e2ac 100755
--- a/service/Application/Admin/Controller/OrderController.class.php
+++ b/service/Application/Admin/Controller/OrderController.class.php
@@ -318,6 +318,30 @@ class OrderController extends CommonController
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
}
+ /**
+ * [Confirm 订单确认]
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 0.0.1
+ * @datetime 2016-12-15T11:03:30+0800
+ */
+ public function Confirm()
+ {
+ // 是否ajax请求
+ if(!IS_AJAX)
+ {
+ $this->error(L('common_unauthorized_access'));
+ }
+
+ // 订单确认
+ $params = $_POST;
+ $params['user_id'] = $params['value'];
+ $params['creator'] = $this->admin['id'];
+ $params['creator_name'] = $this->admin['username'];
+ $ret = OrderService::OrderConfirm($params);
+ $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
+ }
+
/**
* 订单支付
* @author Devil
diff --git a/service/Application/Admin/View/Default/Config/Index.html b/service/Application/Admin/View/Default/Config/Index.html
index a4911c5e8..eac7de556 100755
--- a/service/Application/Admin/View/Default/Config/Index.html
+++ b/service/Application/Admin/View/Default/Config/Index.html
@@ -33,6 +33,14 @@
+
+
+
+
value="{{$data.common_share_giving_integral_frequency.value}}" />
diff --git a/service/Application/Admin/View/Default/Goods/SaveInfo.html b/service/Application/Admin/View/Default/Goods/SaveInfo.html
index b4d11a1f9..d4b4f5238 100755
--- a/service/Application/Admin/View/Default/Goods/SaveInfo.html
+++ b/service/Application/Admin/View/Default/Goods/SaveInfo.html
@@ -149,15 +149,15 @@
- checked="true" />
+ checked="true" />
- checked="true" />
+ checked="true" />
- checked="true" />
+ checked="true" />
diff --git a/service/Application/Admin/View/Default/Order/Index.html b/service/Application/Admin/View/Default/Order/Index.html
index 29cd250c5..278572f6b 100755
--- a/service/Application/Admin/View/Default/Order/Index.html
+++ b/service/Application/Admin/View/Default/Order/Index.html
@@ -216,6 +216,9 @@
+
+
+
diff --git a/service/Application/Home/View/Default/Buy/Index.html b/service/Application/Home/View/Default/Buy/Index.html
index 1507063de..5e5d74980 100755
--- a/service/Application/Home/View/Default/Buy/Index.html
+++ b/service/Application/Home/View/Default/Buy/Index.html
@@ -275,7 +275,7 @@ function BuySubmitBack(e)
}
setTimeout(function()
{
- window.location.href = e.data.pay_url;
+ window.location.href = e.data.jump_url;
}, 1500);
} else {
$('form.form-validation').find('button[type="submit"]').button('reset');
diff --git a/service/Application/Home/View/Default/Goods/Index.html b/service/Application/Home/View/Default/Goods/Index.html
index 5afb05b54..6014069fc 100755
--- a/service/Application/Home/View/Default/Goods/Index.html
+++ b/service/Application/Home/View/Default/Goods/Index.html
@@ -118,7 +118,7 @@
-
+
-
@@ -184,46 +184,51 @@
-
+
-
-
-
- 首页
-
-
-
- 已收藏
- ({{$goods.favor_count}})
-
-
- 收藏
- ({{$goods.favor_count}})
-
-
-
-
-
-
+
+
+
+
+ 首页
+
+
+
+ 已收藏
+ ({{$goods.favor_count}})
+
+
+ 收藏
+ ({{$goods.favor_count}})
+
+
-
-
-
-
-
-
- 商品已下架
-
+
+
+
+ 商品卖光了
+
+
+
+ 商品已下架
+
diff --git a/service/Application/Service/BuyService.class.php b/service/Application/Service/BuyService.class.php
index 9cdcfa1a1..6c2a7f2b7 100755
--- a/service/Application/Service/BuyService.class.php
+++ b/service/Application/Service/BuyService.class.php
@@ -599,15 +599,18 @@ class BuyService
'receive_county' => $address['data']['county'],
'receive_address' => $address['data']['address'],
'user_note' => I('user_note', null, null, $params),
- 'status' => 1,
+ 'status' => (intval(MyC('common_order_is_booking', 0)) == 1) ? 0 : 1,
'preferential_price' => $preferential_price,
'price' => $check['data']['total_price'],
'total_price' => $check['data']['total_price']-$preferential_price,
'express_id' => intval($params['express_id']),
'payment_id' => intval($params['payment_id']),
'add_time' => time(),
- 'confirm_time' => time(),
];
+ if($order['status'] == 1)
+ {
+ $order['confirm_time'] = time();
+ }
// 开始事务
$m = M('Order');
@@ -644,12 +647,32 @@ class BuyService
return DataReturn('订单添加失败', -1);
}
+ // 库存扣除
+ if($order['status'] == 1)
+ {
+ $ret = self::OrderInventoryDeduct(['order_id'=>$order_id, 'order_data'=>$order]);
+ if($ret['status'] != 0)
+ {
+ // 事务回滚
+ $m->rollback();
+ return DataReturn($ret['msg'], -10);
+ }
+ }
+
+
// 订单提交成功
$m->commit();
// 删除购物车
self::BuyCartDelete($params);
+ // 返回信息
+ $result = [
+ 'order' => $m->find($order_id),
+ 'jump_url' => U('Home/Order/Index'),
+ ];
+
+
// 获取订单信息
switch($order['status'])
{
@@ -661,6 +684,7 @@ class BuyService
// 提交成功
case 1 :
$msg = L('common_submit_success');
+ $result['jump_url'] = U('Home/Order/Pay', ['id'=>$order_id]);
break;
// 默认操作成功
@@ -668,10 +692,6 @@ class BuyService
$msg = L('common_operation_success');
}
- $result = [
- 'order' => $m->find($order_id),
- 'pay_url' => U('Home/Order/Pay', ['id'=>$order_id]),
- ];
return DataReturn($msg, 0, $result);
}
@@ -795,25 +815,30 @@ class BuyService
$log_m = M('OrderGoodsInventoryLog');
foreach($order_detail as $v)
{
- $goods = $goods_m->field('is_deduction_inventory,inventory')->find($v['goods_id']);
- if(isset($goods['is_deduction_inventory']) && $goods['is_deduction_inventory'] == 1)
+ // 查看是否已扣除过库存,避免更改模式导致重复扣除
+ $temp = $log_m->where(['order_id'=>$params['order_id'], 'goods_id'=>$v['goods_id']])->find();
+ if(empty($temp))
{
- // 扣除操作
- if(!$goods_m->where(['id'=>$v['goods_id']])->setDec('inventory', $v['buy_number']))
+ $goods = $goods_m->field('is_deduction_inventory,inventory')->find($v['goods_id']);
+ if(isset($goods['is_deduction_inventory']) && $goods['is_deduction_inventory'] == 1)
{
- return DataReturn('库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
- }
+ // 扣除操作
+ if(!$goods_m->where(['id'=>$v['goods_id']])->setDec('inventory', $v['buy_number']))
+ {
+ return DataReturn('库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
+ }
- // 扣除日志添加
- $log_data = [
- 'order_id' => $params['order_id'],
- 'goods_id' => $v['goods_id'],
- 'order_status' => $params['order_data']['status'],
- 'original_inventory' => $goods['inventory'],
- 'new_inventory' => $goods['inventory']+$v['buy_number'],
- 'add_time' => time(),
- ];
- $log_m->add($log_data);
+ // 扣除日志添加
+ $log_data = [
+ 'order_id' => $params['order_id'],
+ 'goods_id' => $v['goods_id'],
+ 'order_status' => $params['order_data']['status'],
+ 'original_inventory' => $goods['inventory'],
+ 'new_inventory' => $goods_m->where(['id'=>$v['goods_id']])->getField('inventory'),
+ 'add_time' => time(),
+ ];
+ $log_m->add($log_data);
+ }
}
}
}
diff --git a/service/Application/Service/OrderService.class.php b/service/Application/Service/OrderService.class.php
index 222fc276a..efb525e40 100755
--- a/service/Application/Service/OrderService.class.php
+++ b/service/Application/Service/OrderService.class.php
@@ -734,24 +734,41 @@ class OrderService
return DataReturn('状态不可操作['.$status_text.']', -1);
}
- $data = [
+ // 开启事务
+ $m->startTrans();
+ $upd_data = [
'status' => 3,
'express_id' => intval($params['express_id']),
'express_number' => I('express_number', '', '', $params),
'delivery_time' => time(),
'upd_time' => time(),
];
- if($m->where($where)->save($data))
+ if($m->where($where)->save($upd_data))
{
+ // 库存扣除
+ $ret = BuyService::OrderInventoryDeduct(['order_id'=>$params['id'], 'order_data'=>$upd_data]);
+ if($ret['status'] != 0)
+ {
+ // 事务回滚
+ $m->rollback();
+ return DataReturn($ret['msg'], -10);
+ }
+
// 用户消息
MessageService::MessageAdd($order['user_id'], '订单发货', '订单已发货', 1, $order['id']);
// 订单状态日志
$creator = isset($params['creator']) ? intval($params['creator']) : 0;
$creator_name = isset($params['creator_name']) ? htmlentities($params['creator_name']) : '';
- self::OrderHistoryAdd($order['id'], $data['status'], $order['status'], '收货', $creator, $creator_name);
+ self::OrderHistoryAdd($order['id'], $upd_data['status'], $order['status'], '收货', $creator, $creator_name);
+
+ // 提交事务
+ $m->commit();
return DataReturn(L('common_operation_delivery_success'), 0);
}
+
+ // 事务回滚
+ $m->rollback();
return DataReturn(L('common_operation_delivery_error'), -1);
}
@@ -799,12 +816,13 @@ class OrderService
return DataReturn('状态不可操作['.$status_text.']', -1);
}
- $data = [
+ // 更新订单状态
+ $upd_data = [
'status' => 4,
'collect_time' => time(),
'upd_time' => time(),
];
- if($m->where($where)->save($data))
+ if($m->where($where)->save($upd_data))
{
// 用户消息
MessageService::MessageAdd($order['user_id'], '订单收货', '订单收货成功', 1, $order['id']);
@@ -812,12 +830,94 @@ class OrderService
// 订单状态日志
$creator = isset($params['creator']) ? intval($params['creator']) : 0;
$creator_name = isset($params['creator_name']) ? htmlentities($params['creator_name']) : '';
- self::OrderHistoryAdd($order['id'], $data['status'], $order['status'], '收货', $creator, $creator_name);
+ self::OrderHistoryAdd($order['id'], $upd_data['status'], $order['status'], '收货', $creator, $creator_name);
return DataReturn(L('common_operation_collect_success'), 0);
}
return DataReturn(L('common_operation_collect_error'), -1);
}
+ /**
+ * 订单确认
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-09-30
+ * @desc description
+ * @param [array] $params [输入参数]
+ */
+ public static function OrderConfirm($params = [])
+ {
+ // 请求参数
+ $p = [
+ [
+ 'checked_type' => 'empty',
+ 'key_name' => 'id',
+ 'error_msg' => '订单id有误',
+ ],
+ [
+ 'checked_type' => 'empty',
+ 'key_name' => 'user_id',
+ 'error_msg' => '用户id有误',
+ ],
+ ];
+ $ret = params_checked($params, $p);
+ if($ret !== true)
+ {
+ return DataReturn($ret, -1);
+ }
+
+ // 获取订单信息
+ $m = M('Order');
+ $where = ['id'=>intval($params['id']), 'user_id'=>$params['user_id'], 'is_delete_time'=>0, 'user_is_delete_time'=>0];
+ $order = $m->where($where)->field('id,status,user_id')->find();
+ if(empty($order))
+ {
+ return DataReturn(L('common_data_no_exist_error'), -1);
+ }
+ if(!in_array($order['status'], [0]))
+ {
+ $status_text = L('common_order_admin_status')[$order['status']]['name'];
+ return DataReturn('状态不可操作['.$status_text.']', -1);
+ }
+
+ // 开启事务
+ $m->startTrans();
+
+ // 更新订单状态
+ $upd_data = [
+ 'status' => 1,
+ 'confirm_time' => time(),
+ 'upd_time' => time(),
+ ];
+ if($m->where($where)->save($upd_data))
+ {
+ // 库存扣除
+ $ret = BuyService::OrderInventoryDeduct(['order_id'=>$params['id'], 'order_data'=>$upd_data]);
+ if($ret['status'] != 0)
+ {
+ // 事务回滚
+ $m->rollback();
+ return DataReturn($ret['msg'], -10);
+ }
+
+ // 用户消息
+ MessageService::MessageAdd($order['user_id'], '订单确认', '订单确认成功', 1, $order['id']);
+
+ // 订单状态日志
+ $creator = isset($params['creator']) ? intval($params['creator']) : 0;
+ $creator_name = isset($params['creator_name']) ? htmlentities($params['creator_name']) : '';
+ self::OrderHistoryAdd($order['id'], $upd_data['status'], $order['status'], '确认', $creator, $creator_name);
+
+ // 事务提交
+ $m->commit();
+ return DataReturn(L('common_confirm_success'), 0);
+ }
+
+ // 事务回滚
+ $m->rollback();
+ return DataReturn(L('common_confirm_error'), -1);
+ }
+
/**
* 订单删除
* @author Devil
diff --git a/service/Public/Home/Default/Css/Goods.css b/service/Public/Home/Default/Css/Goods.css
index 321ea5611..ed3ecf993 100755
--- a/service/Public/Home/Default/Css/Goods.css
+++ b/service/Public/Home/Default/Css/Goods.css
@@ -289,7 +289,7 @@ li.am-comment{ width:100%}
.nav.white,.tip{z-index:999}
/* 文字提示 */
-.shelves-tips { color: #FF5722; margin: 5px 0; font-size: 14px; }
+.goods-not-buy-tips { color: #FF5722; margin: 5px 0; font-size: 14px; }
@media only screen and (min-width:640px) {
/*导航固定*/
@@ -456,7 +456,7 @@ li.am-comment{ width:100%}
/* 推荐商品 */
.like li:not(:nth-of-type(2n)) { border-right: 1px solid #eee; }
.like li:nth-child(1), .like li:nth-child(2) { border-top: 0px; }
- .shelves-tips { text-align: center; }
+ .goods-not-buy-tips { text-align: center; }
.goods-favor-count { display: none; }
/* 视频操作 */
|