|
@@ -18,7 +18,6 @@ use app\common\model\PaymentChannelModel;
|
|
|
use app\common\model\ProductModel;
|
|
use app\common\model\ProductModel;
|
|
|
use app\common\model\StoreModel;
|
|
use app\common\model\StoreModel;
|
|
|
use app\common\model\StoreProductModel;
|
|
use app\common\model\StoreProductModel;
|
|
|
-use think\cache\driver\Redis;
|
|
|
|
|
use think\facade\Db;
|
|
use think\facade\Db;
|
|
|
|
|
|
|
|
class OrderService extends \app\BaseService
|
|
class OrderService extends \app\BaseService
|
|
@@ -131,13 +130,18 @@ class OrderService extends \app\BaseService
|
|
|
// 总消费税
|
|
// 总消费税
|
|
|
$total_sales_tax = 0;
|
|
$total_sales_tax = 0;
|
|
|
$advisor_1_ids = [];
|
|
$advisor_1_ids = [];
|
|
|
|
|
+ $product_names = [];
|
|
|
|
|
+ $order_no = $this->orderModel->genOrderNo($store->id, $store->abbr);
|
|
|
for ($i = 0; $i < count($store_products_params); $i++) {
|
|
for ($i = 0; $i < count($store_products_params); $i++) {
|
|
|
$store_products_param = $store_products_params[$i];
|
|
$store_products_param = $store_products_params[$i];
|
|
|
$store_product = $fmt_store_products[$store_products_param->store_product_id];
|
|
$store_product = $fmt_store_products[$store_products_param->store_product_id];
|
|
|
array_push($advisor_1_ids, $store_products_param->adviser_1_id);
|
|
array_push($advisor_1_ids, $store_products_param->adviser_1_id);
|
|
|
for ($j = 0; $j < $store_products_param->quantity; $j++) {
|
|
for ($j = 0; $j < $store_products_param->quantity; $j++) {
|
|
|
|
|
+ array_push($product_names, $store_product['product']['name']);
|
|
|
array_push($order_products, [
|
|
array_push($order_products, [
|
|
|
'order_id' => 0,
|
|
'order_id' => 0,
|
|
|
|
|
+ 'order_no' => $order_no,
|
|
|
|
|
+ 'customer_id' => $customer->id,
|
|
|
'product_id' => $store_product['product']['id'],
|
|
'product_id' => $store_product['product']['id'],
|
|
|
'store_product_id' => $store_product['id'],
|
|
'store_product_id' => $store_product['id'],
|
|
|
'product_name' => $store_product['product']['name'],
|
|
'product_name' => $store_product['product']['name'],
|
|
@@ -167,9 +171,10 @@ class OrderService extends \app\BaseService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$order = $this->orderModel->create([
|
|
$order = $this->orderModel->create([
|
|
|
- 'no' => $this->orderModel->genOrderNo($store->id, $store->abbr),
|
|
|
|
|
|
|
+ 'no' => $order_no,
|
|
|
'customer_id' => $customer->id,
|
|
'customer_id' => $customer->id,
|
|
|
'customer_name' => $customer->name_en,
|
|
'customer_name' => $customer->name_en,
|
|
|
|
|
+ 'obj_names' => join(',',array_unique($product_names)),
|
|
|
'rental_amount' => $rental_amount,
|
|
'rental_amount' => $rental_amount,
|
|
|
'receivable_amount' => $rental_amount,
|
|
'receivable_amount' => $rental_amount,
|
|
|
'receive_amount' => 0,
|
|
'receive_amount' => 0,
|
|
@@ -352,7 +357,7 @@ class OrderService extends \app\BaseService
|
|
|
'service_charge_amount' => $order->service_charge_amount + $service_charge,
|
|
'service_charge_amount' => $order->service_charge_amount + $service_charge,
|
|
|
];
|
|
];
|
|
|
if (round($receive_amount) == round($imposed_amount)) { // 支付满了
|
|
if (round($receive_amount) == round($imposed_amount)) { // 支付满了
|
|
|
- $update_order['type'] = 2;
|
|
|
|
|
|
|
+ $update_order['type'] = 1;
|
|
|
Db::table('erp_order_product')->where('order_id', $order->id)->update(['is_pay' => 1]);
|
|
Db::table('erp_order_product')->where('order_id', $order->id)->update(['is_pay' => 1]);
|
|
|
if(count($order_annual_fees) > 0) {
|
|
if(count($order_annual_fees) > 0) {
|
|
|
Db::table('erp_order_annual_fee')->insertAll($order_annual_fees);
|
|
Db::table('erp_order_annual_fee')->insertAll($order_annual_fees);
|
|
@@ -399,6 +404,53 @@ class OrderService extends \app\BaseService
|
|
|
return $this->ok(true);
|
|
return $this->ok(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public function fetch($params) {
|
|
|
|
|
+ $is_look_all = AuthService::is_look_all($params['admin_id'],$params['type'] == 1 ? 10003 : 10004);
|
|
|
|
|
+ $res = $this->orderModel->search($params, $is_look_all);
|
|
|
|
|
+ $items = $res['data'];
|
|
|
|
|
+ foreach ($items as &$item) {
|
|
|
|
|
+ $item['is_need_upload'] = $item['type'] == 1 && in_array(true, array_map(function ($product) {
|
|
|
|
|
+ return $product['is_upload_numerology'] == 1 && $product['is_upload'] == 0;
|
|
|
|
|
+ }, $item['products']));
|
|
|
|
|
+ }
|
|
|
|
|
+ return [$items, $res['total']];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param $params
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function fetchByCustomerId($params) {
|
|
|
|
|
+ $res = $this->orderModel->fetchByCustomerId($params['customer_id'], $params['page'] ?? 1, $params['size'] ?? 20);
|
|
|
|
|
+ $items = $res['data'];
|
|
|
|
|
+ foreach ($items as &$item) {
|
|
|
|
|
+ $item['is_need_upload'] = $item['type'] == 1 && in_array(true, array_map(function ($product) {
|
|
|
|
|
+ return $product['is_upload_numerology'] == 1 && $product['is_upload'] == 0;
|
|
|
|
|
+ }, $item['products']));
|
|
|
|
|
+ }
|
|
|
|
|
+ return [$items, $res['total']];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public function upload_numerology($order_product_id, $report) {
|
|
|
|
|
+ $order_product = $this->orderProductModel->findById($order_product_id);
|
|
|
|
|
+ if (!$order_product) return $this->fail('订单商品不存在,无法上传命理报告!');
|
|
|
|
|
+ if (!$order_product->is_pay) return $this->fail('订单未支付,无法上传商品');
|
|
|
|
|
+ $order_product->is_upload = 1;
|
|
|
|
|
+ $order_product->report = $report;
|
|
|
|
|
+ $order_product->save();
|
|
|
|
|
+ return $this->ok($order_product);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|