feat(admin): 添加采购产品报价单相关功能

- 在 BeforehandOrderLists 中添加 order_sn 字段
- 在 PurchaseProductOfferLogic 中增加产品信息和单位名称的获取
- 添加报价单推送功能
- 优化报价单数据处理逻辑,增加支付类型名称
This commit is contained in:
mkm 2024-11-20 11:54:23 +08:00
parent e45226ffe0
commit 4d3135ed8c
3 changed files with 53 additions and 3 deletions

View File

@ -68,7 +68,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
break;
}
return BeforehandOrder::where($this->searchWhere)
->field(['id', 'order_id', 'store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file'])
->field(['id', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {

View File

@ -12,6 +12,8 @@ use app\common\model\delivery_service\DeliveryService;
use app\common\model\dict\DictData;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_price\StoreProductPrice;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\service\workWechat\ProductOffer;
use support\exception\BusinessException;
use think\facade\Db;
@ -136,8 +138,9 @@ class PurchaseProductOfferLogic extends BaseLogic
'after_sales' => $params['after_sales'],
]);
$find = StoreProductPrice::where(['offer_id' => $params['id']])->find();
$top_cate_id = StoreProduct::where('id', $offer['product_id'])->value('top_cate_id');
$dict_data = DictData::where('type_value', 'price_lv_' . $top_cate_id)->field('name,value')->select();
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('store_name,top_cate_id')->find();
$unit_name=StoreProductUnit::where('id', $offer['unit_id'])->value('name');
$dict_data = DictData::where('type_value', 'price_lv_' . $product['top_cate_id'])->field('name,value')->select();
$data = [];
$data['bhoid'] = $offer['order_id'];
$data['offer_id'] = $params['id'];
@ -167,6 +170,16 @@ class PurchaseProductOfferLogic extends BaseLogic
StoreProductPrice::create($data);
}
Db::commit();
$offer['store_name']=$product['store_name'];
$offer['unit_name']=$unit_name;
if($offer['pay_type']==1){
$offer['pay_type_name']='赊账';
}elseif($offer['pay_type']==2){
$offer['pay_type_name']='现金';
}else{
$offer['pay_type_name']='没设置';
}
ProductOffer::push($offer);
return true;
} catch (\Throwable $e) {
Db::rollback();

View File

@ -0,0 +1,37 @@
<?php
namespace app\common\service\workWechat;
use app\common\service\Curl;
use support\Log;
class ProductOffer
{
public static function push($data)
{
try {
$url = getenv('PUSHPRODUCTOFFER');
$order_id = $data['order_id'];
$store_name = $data['store_name'];
$num = $data['buyer_nums'];
$unit_name = $data['unit_name'];
$price = $data['price'];
$create_time = $data['create_time'];
$buyer_name = $data['buyer_name'];
$pay_type = $data['pay_type_name'];
$url=getenv('APP_URL')."/api/purchase_product_offer?date=".$data['create_time'];
$arr = ["msgtype" => "markdown", "markdown" => ["content" => "有新的采购商品
>订单ID:<font color=\"comment\">$order_id</font>
>商品名称:<font color=\"comment\">$store_name</font>
>数量/单位:<font color=\"comment\">$num/$unit_name</font>
>采购人:<font color=\"comment\">$buyer_name</font>
>采购金额:<font color=\"comment\">$price</font>
>采购时间:<font color=\"comment\">$create_time</font>
>支付方式:<font color=\"comment\">$pay_type</font>
[下载今日采购表格]($url)"]];
(new Curl())->postJson($url, json_encode($arr, true));
} catch (\Throwable $e) {
Log::error('推送商品信息保存:'.$e->getMessage());
}
}
}