From 83c9f6cbc4d0453041662c1d1a48361498fd973d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 12 Mar 2021 16:08:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin_data.sql | 23 ++++++++++++----------- app/data/controller/ShopOrder.php | 9 +++------ app/data/controller/api/auth/Order.php | 7 ++++--- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/admin_data.sql b/admin_data.sql index 37ffe41e5..432c8b8ed 100644 --- a/admin_data.sql +++ b/admin_data.sql @@ -11,7 +11,7 @@ Target Server Version : 50562 File Encoding : 65001 - Date: 12/03/2021 15:54:21 + Date: 12/03/2021 16:07:52 */ SET NAMES utf8mb4; @@ -603,27 +603,28 @@ CREATE TABLE `shop_order` ( `payment_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实际支付平台', `payment_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实际通道编号', `payment_trade` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实际支付单号', - `payment_status` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '实际支付状态', + `payment_status` tinyint(1) NULL DEFAULT 0 COMMENT '实际支付状态', `payment_image` varchar(999) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '支付凭证图片', `payment_amount` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '实际支付金额', `payment_balance` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '余额抵扣金额', `payment_remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '支付结果描述', `payment_datetime` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '支付到账时间', - `truck_type` tinyint(1) NULL DEFAULT 0 COMMENT '物流配送(0无需配送,1需要配送)', `number_goods` bigint(20) NULL DEFAULT 0 COMMENT '订单商品数量', - `cancel_status` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '订单取消状态', + `number_express` bigint(20) NULL DEFAULT 0 COMMENT '订单快递计数', + `truck_type` tinyint(1) NULL DEFAULT 0 COMMENT '物流配送(0无需配送,1需要配送)', + `cancel_status` tinyint(1) NULL DEFAULT 0 COMMENT '订单取消状态', `cancel_remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '订单取消描述', `cancel_datetime` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '订单取消时间', - `deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '订单删除状态(0未删,1已删)', + `deleted_status` tinyint(1) NULL DEFAULT 0 COMMENT '订单删除状态(0未删,1已删)', `deleted_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '订单删除描述', `deleted_datetime` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '订单删除时间', - `status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '订单状态(0已取消,1预订单,2待支付,3支付中,4已支付,5已发货,6已完成)', + `status` tinyint(1) NULL DEFAULT 1 COMMENT '订单状态(0已取消,1预订单,2待支付,3支付中,4已支付,5已发货,6已完成)', `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE, INDEX `idx_shop_order_mid`(`uid`) USING BTREE, INDEX `idx_shop_order_from`(`puid1`) USING BTREE, INDEX `idx_shop_order_status`(`status`) USING BTREE, - INDEX `idx_shop_order_deleted`(`deleted`) USING BTREE, + INDEX `idx_shop_order_deleted`(`deleted_status`) USING BTREE, INDEX `idx_shop_order_orderno`(`order_no`) USING BTREE, INDEX `idx_shop_order_cancel_status`(`cancel_status`) USING BTREE, INDEX `idx_shop_order_payment_status`(`payment_status`) USING BTREE @@ -632,9 +633,9 @@ CREATE TABLE `shop_order` ( -- ---------------------------- -- Records of shop_order -- ---------------------------- -INSERT INTO `shop_order` VALUES (1, 1, 0, 0, 'N20210311513872036', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, NULL, 'empty', 'empty', '20210311695844329692', 1, '', 0.00, 0.00, '无需支付', '2021-03-11 17:52:58', 0, 1, 0, '', '', 0, '', '', 4, '2021-03-11 09:15:09'); -INSERT INTO `shop_order` VALUES (2, 1, 0, 0, 'N20210311715437924', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, NULL, 'empty', 'empty', '20210311721982820832', 1, '', 0.00, 0.00, '无需支付', '2021-03-11 17:55:19', 0, 1, 0, '', '', 0, '', '', 4, '2021-03-11 09:35:25'); -INSERT INTO `shop_order` VALUES (3, 1, 0, 0, 'N20210311745121809', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, NULL, 'empty', 'empty', '20210311750726151684', 1, '', 0.00, 0.00, '无需支付', '2021-03-11 17:58:07', 0, 1, 0, '', '', 0, '', '', 4, '2021-03-11 09:38:21'); +INSERT INTO `shop_order` VALUES (1, 1, 0, 0, 'N20210311513872036', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, NULL, 'empty', 'empty', '20210311695844329692', 1, '', 0.00, 0.00, '无需支付', '2021-03-11 17:52:58', 1, 0, 0, 0, '', '', 0, '', '', 4, '2021-03-11 09:15:09'); +INSERT INTO `shop_order` VALUES (2, 1, 0, 0, 'N20210311715437924', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, NULL, 'empty', 'empty', '20210311721982820832', 1, '', 0.00, 0.00, '无需支付', '2021-03-11 17:55:19', 1, 0, 0, 0, '', '', 0, '', '', 4, '2021-03-11 09:35:25'); +INSERT INTO `shop_order` VALUES (3, 1, 0, 0, 'N20210311745121809', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, NULL, 'empty', 'empty', '20210311750726151684', 1, '', 0.00, 0.00, '无需支付', '2021-03-11 17:58:07', 1, 0, 0, 0, '', '', 0, '', '', 4, '2021-03-11 09:38:21'); -- ---------------------------- -- Table structure for shop_order_item @@ -660,7 +661,7 @@ CREATE TABLE `shop_order_item` ( `stock_sales` bigint(20) NULL DEFAULT 1 COMMENT '商品数量', `truck_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '物流配送(0无需配送,1需要配送)', `truck_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '快递邮费模板', - `truck_count` bigint(20) NULL DEFAULT 0 COMMENT '快递计费基数', + `truck_number` bigint(20) NULL DEFAULT 0 COMMENT '快递计费基数', `vip_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户等级名称', `vip_entry` tinyint(1) NULL DEFAULT 0 COMMENT '是否入会礼包', `vip_number` bigint(20) NULL DEFAULT 0 COMMENT '用户等级序号', diff --git a/app/data/controller/ShopOrder.php b/app/data/controller/ShopOrder.php index 0fb466998..df2188ce1 100644 --- a/app/data/controller/ShopOrder.php +++ b/app/data/controller/ShopOrder.php @@ -72,7 +72,7 @@ class ShopOrder extends Controller $query->where(['status' => $this->type]); } // 分页排序处理 - $query->where(['deleted' => 0])->order('id desc')->page(); + $query->where(['deleted_status' => 0])->order('id desc')->page(); } /** @@ -174,12 +174,9 @@ class ShopOrder extends Controller */ public function cancel() { - $map = $this->_vali([ - 'deleted.value' => 0, - 'order_no.require' => '订单编号不能为空!', - ]); + $map = $this->_vali(['order_no.require' => '订单号不能为空!',]); $order = $this->app->db->name($this->table)->where($map)->find(); - if (empty($order)) $this->error('订单查询异常'); + if (empty($order)) $this->error('订单查询异常!'); if (!in_array($order['status'], [1, 2, 3])) $this->error('订单不能取消!'); try { $result = $this->app->db->name($this->table)->where($map)->update([ diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index cc42f3c79..8f77703b3 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -116,7 +116,7 @@ class Order extends Auth // 快递发货数据 'truck_type' => $goodsInfo['truck_type'], 'truck_code' => $goodsInfo['truck_code'], - 'truck_count' => $goodsItem['number_express'] * $count, + 'truck_number' => $goodsInfo['rebate_type'] > 0 ? $goodsItem['number_express'] * $count : 0, // 商品费用字段 'price_market' => $goodsItem['price_market'], 'price_selling' => $goodsItem['price_selling'], @@ -149,6 +149,7 @@ class Order extends Auth $order['truck_type'] = $truckType; // 统计商品数量 $order['number_goods'] = array_sum(array_column($items, 'stock_sales')); + $order['number_express'] = array_sum(array_column($items, 'truck_number')); // 统计商品金额 $order['amount_goods'] = array_sum(array_column($items, 'total_selling')); // 优惠后的金额 @@ -202,7 +203,7 @@ class Order extends Auth if (empty($addr)) $this->error('收货地址异常'); // 订单状态检查 $map = ['uid' => $this->uuid, 'order_no' => $data['order_no']]; - $tCount = $this->app->db->name('ShopOrderItem')->where($map)->sum('truck_count'); + $tCount = $this->app->db->name('ShopOrderItem')->where($map)->sum('truck_number'); // 根据地址计算运费 $map = ['status' => 1, 'deleted' => 0, 'order_no' => $data['order_no']]; $tCode = $this->app->db->name('ShopOrderItem')->where($map)->column('truck_code'); @@ -230,7 +231,7 @@ class Order extends Auth // 订单状态检查 $map = ['uid' => $this->uuid, 'order_no' => $data['order_no']]; $order = $this->app->db->name('ShopOrder')->where($map)->whereIn('status', [1, 2])->find(); - $tCount = $this->app->db->name('ShopOrderItem')->where($map)->sum('truck_count'); + $tCount = $this->app->db->name('ShopOrderItem')->where($map)->sum('truck_number'); if (empty($order)) $this->error('不能修改地址'); // 根据地址计算运费 $map = ['status' => 1, 'deleted' => 0, 'order_no' => $data['order_no']];