diff --git a/crmeb/app/adminapi/controller/v1/order/StoreOrder.php b/crmeb/app/adminapi/controller/v1/order/StoreOrder.php index 3e253858c..414a010d7 100644 --- a/crmeb/app/adminapi/controller/v1/order/StoreOrder.php +++ b/crmeb/app/adminapi/controller/v1/order/StoreOrder.php @@ -323,18 +323,42 @@ class StoreOrder extends AuthController $data = $this->request->postMore([ ['kuaidicom', ''], ['send_address', ''], - ['address', ''], - ['weight', ''], + ['orderId', ''], ['service_type', ''], ['cart_ids', []], ]); - foreach ($data['cart_ids'] as $cart) { - if (!isset($cart['cart_id']) || !$cart['cart_id'] || !isset($cart['cart_num']) || !$cart['cart_num']) { - return app('json')->fail(400159); + $orderInfo = $this->services->get($data['orderId'], ['user_address', 'cart_id']); + if (!$orderInfo) { + return app('json')->fail('订单没有查询到'); + } + $weight = '0'; + if ($data['cart_ids']) { + $cartIds = array_column($data['cart_ids'], 'cart_id'); + $cartList = app()->make(StoreOrderCartInfoServices::class)->getColumn([ + ['cart_id', 'in', $cartIds] + ], 'cart_info', 'cart_id'); + foreach ($data['cart_ids'] as $cart) { + if (!isset($cart['cart_id']) || !$cart['cart_id'] || !isset($cart['cart_num']) || !$cart['cart_num']) { + return app('json')->fail(400159); + } + if (isset($cartList[$cart['cart_id']])) { + $value = is_string($cartList[$cart['cart_id']]) ? json_decode($cartList[$cart['cart_id']], true) : $cartList[$cart['cart_id']]; + $weightnew = bcmul($value['attrInfo']['weight'], (string)$cart['cart_num'], 2); + $weight = bcadd($weightnew, $weight, 2); + } + } + } else { + $orderCartInfoList = app()->make(StoreOrderCartInfoServices::class)->getCartInfoPrintProduct($data['orderId']); + foreach ($orderCartInfoList as $item) { + $weightnew = bcmul($item['attrInfo']['weight'], (string)$item['cart_num'], 2); + $weight = bcadd($weightnew, $weight, 2); } } - + $data['address'] = $orderInfo['user_address']; + if ($weight > 0) { + $data['weight'] = $weight; + } return app('json')->success($services->express()->getPrice($data)); } diff --git a/crmeb/crmeb/services/express/storage/Express.php b/crmeb/crmeb/services/express/storage/Express.php index 9421f4a22..1705ac371 100644 --- a/crmeb/crmeb/services/express/storage/Express.php +++ b/crmeb/crmeb/services/express/storage/Express.php @@ -180,7 +180,7 @@ class Express extends BaseExpress throw new ApiException('收件地址必须填写'); } $param = [ - 'kuaidi_num' => $data['kuaidicom'], + 'kuaidicom' => $data['kuaidicom'], 'send_address' => $data['send_address'], 'address' => $data['address'] ?? '', 'weight' => $data['weight'] ?? '', diff --git a/crmeb/public/install/crmeb.sql b/crmeb/public/install/crmeb.sql index aafb84d66..28367a604 100755 --- a/crmeb/public/install/crmeb.sql +++ b/crmeb/public/install/crmeb.sql @@ -28438,6 +28438,7 @@ CREATE TABLE IF NOT EXISTS `eb_store_order` ( `pay_type` varchar(32) NOT NULL DEFAULT '' COMMENT '支付方式', `add_time` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间', `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款)', + `is_stock_up` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否备货中', `refund_status` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0 未退款 1 申请中 2 已退款', `refund_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '退款申请类型', `refund_express` varchar(255) NOT NULL DEFAULT '' COMMENT '退货快递单号', diff --git a/template/admin/src/api/order.js b/template/admin/src/api/order.js index 36a66ad50..0143db089 100644 --- a/template/admin/src/api/order.js +++ b/template/admin/src/api/order.js @@ -502,6 +502,17 @@ export function otherBatchDelivery(data) { data, }); } +/** + * @description 商家寄件金额计算 + * @param {Object} param data {Object} 传值参数 + */ +export function orderPrice(data) { + return request({ + url: 'order/price', + method: 'post', + data, + }); +} /** * @description 重新执行 * @param {Object} param data {Object} 传值参数 diff --git a/template/admin/src/pages/order/orderList/handle/orderSend.vue b/template/admin/src/pages/order/orderList/handle/orderSend.vue index fb633636e..3f75ec4ed 100644 --- a/template/admin/src/pages/order/orderList/handle/orderSend.vue +++ b/template/admin/src/pages/order/orderList/handle/orderSend.vue @@ -18,9 +18,9 @@ - 手动填写 - 电子面单打印 商家寄件 + 录入单号 + 电子面单打印
@@ -40,6 +40,11 @@ > + + +
@@ -152,6 +157,9 @@ + + +
@@ -177,6 +185,7 @@ import { orderSheetInfo, splitCartInfo, kuaidiComsList, + orderPrice, } from '@/api/order'; import printJS from 'print-js'; export default { @@ -192,6 +201,10 @@ export default { orderId(val) { if (this.virtual_type == 3) this.formItem.type = '3'; }, + modals(newVal) { + if (newVal) { + } + }, }, data() { return { @@ -200,7 +213,7 @@ export default { splitSwitch: true, formItem: { type: '1', - express_record_type: '1', + express_record_type: '3', delivery_name: '', delivery_id: '', express_temp_id: '', @@ -209,6 +222,7 @@ export default { to_addr: '', sh_delivery: '', fictitious_content: '', + service_type: '', day_type: 0, }, modals: false, @@ -280,9 +294,38 @@ export default { }, ], selectData: [], + serviceTypeList: [], }; }, + mounted() { + this.kuaidiComsList(1); + let delData; + if (localStorage.getItem('DELIVERY_DATA')) delData = JSON.parse(localStorage.getItem('DELIVERY_DATA')); + if (delData) { + this.formItem.delivery_name = delData.delivery_name; + this.formItem.delivery_code = delData.delivery_code; + } + }, methods: { + watchPrice() { + console.log(1111); + let data = { + kuaidicom: this.formItem.delivery_code, + send_address: this.formItem.to_addr, + orderId: this.orderId, + service_type: this.formItem.service_type, + cart_ids: [], + }; + this.selectData.forEach((v) => { + data.cart_ids.push({ + cart_id: v.cart_id, + cart_num: v.num || v.surplus_num, + }); + }); + orderPrice(data).then((res) => { + console.log(res); + }); + }, selectOne(data) { this.selectData = data; }, @@ -350,22 +393,22 @@ export default { case '3': this.formItem.delivery_name = ''; this.formItem.delivery_id = ''; - this.kuaidiComsList(); break; default: break; } }, - kuaidiComsList() { + kuaidiComsList(status) { kuaidiComsList().then((res) => { console.log(res); this.kuaidiExpress = res.data; + if (this.formItem.delivery_name) this.expressChange(this.formItem.delivery_name); }); }, reset() { this.formItem = { type: '1', - express_record_type: '1', + express_record_type: '3', delivery_name: '', delivery_id: '', express_temp_id: '', @@ -375,6 +418,7 @@ export default { to_addr: '', sh_delivery: '', fictitious_content: '', + service_type: '', }; }, // 物流公司列表 @@ -447,6 +491,7 @@ export default { .then((res) => { this.modals = false; this.$Message.success(res.msg); + localStorage.setItem('DELIVERY_DATA', JSON.stringify(this.formItem)); this.$emit('submitFail'); this.reset(); this.splitSwitch = false; @@ -460,6 +505,7 @@ export default { .then(async (res) => { this.modals = false; this.$Message.success(res.msg); + localStorage.setItem('DELIVERY_DATA', JSON.stringify(this.formItem)); this.splitSwitch = false; this.$emit('submitFail'); this.reset(); @@ -483,6 +529,7 @@ export default { }, // 电子面单列表 expressChange(value) { + this.formItem.service_type = ''; let expressItem = (this.formItem.express_record_type == '3' ? this.kuaidiExpress : this.express).find((item) => { return item.value === value; }); @@ -490,6 +537,7 @@ export default { if (expressItem === undefined) { return; } + this.serviceTypeList = expressItem.types; this.formItem.delivery_code = expressItem.code; if (this.formItem.express_record_type === '2') { this.expressTemp = []; @@ -543,7 +591,7 @@ export default { if (!this.export_open) { this.formItem.express_record_type = '1'; } - this.formItem.to_addr = data.to_add; + // this.formItem.to_addr = data.to_add; }) .catch((err) => { this.$Message.error(err.msg);