Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/admin/logic/operation/OpurchaseclassLogic.php
This commit is contained in:
weiz 2024-05-11 17:28:18 +08:00
commit 773b07537f
6 changed files with 116 additions and 45 deletions

View File

@ -5,6 +5,7 @@ namespace app\admin\controller\operation;
use app\admin\controller\BaseAdminController;
use app\admin\lists\operation\OpurchaseclassLists;
use app\admin\lists\operation\OpurchaseclassofferLists;
use app\admin\logic\operation\OpurchaseclassLogic;
use app\admin\validate\operation\OpurchaseclassValidate;
use app\common\model\goods\Goods;
@ -133,24 +134,8 @@ class OpurchaseclassController extends BaseAdminController
*/
public function goods_offer_list()
{
$id = $this->request->get('id');
$page_no = $this->request->get('page_no', 1);
$params=$this->request->get();
$where['order_id']=$id;
if(isset($params['is_adopt']) && $params['is_adopt']!==''){
$where['is_adopt']=$params['is_adopt'];
}
$res = OpurchaseGoodsOffer::where($where)->page($page_no, 25)->select()->each(function ($item) {
$find = Goods::where('id', $item['goods_id'])->with('unitName')->find();
$item['goods_name'] = $find['name'];
$item['unit_name'] = $find['unit_name'];
$item['supplier_name'] = Supplier::where('id',$item['supplier_id'])->value('mer_name');
});
$data['count'] = Opurchaseinfo::where('pid', $id)->count();
$data['lists'] = $res?->toArray();
$data['page_no'] = $page_no;
$data['page_siz'] = 15;
return $this->success('ok', $data);
return $this->dataLists(new OpurchaseclassofferLists());
}
/**
* @notes 推送给供应商报价
@ -178,9 +163,12 @@ class OpurchaseclassController extends BaseAdminController
public function goods_offer_update()
{
$id = $this->request->post('id');
$result = OpurchaseclassLogic::goodsOfferUpdate($id);
if ($result) {
return $this->success('已采纳', [], 1, 1);
$type = $this->request->post('type');
$notes = $this->request->post('notes');
$nums = $this->request->post('nums');
$result = OpurchaseclassLogic::goodsOfferUpdate($id,$type,$notes,$nums);
if ($result==true) {
return $this->success('已设置', [], 1, 1);
}
return $this->fail(OpurchaseclassLogic::getError());
}

View File

@ -0,0 +1,72 @@
<?php
namespace app\admin\lists\operation;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\operation\Opurchaseclass;
use app\common\lists\ListsSearchInterface;
use app\common\model\goods\Goods;
use app\common\model\opurchase\OpurchaseGoodsOffer;
use app\common\model\supplier\Supplier;
/**
* 采购供应链商户报价
* Class OpurchaseclassofferLists
* @package app\admin\listsoperation
*/
class OpurchaseclassofferLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function setSearch(): array
{
return [
'=' => ['is_adopt'],
];
}
/**
* @notes 获取采购供应链商户报价列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function lists(): array
{
$where=[];
return OpurchaseGoodsOffer::where($this->searchWhere)
->where($where)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
$find = Goods::where('id', $item['goods_id'])->with('unitName')->find();
$item['goods_name'] = $find['name'];
$item['unit_name'] = $find['unit_name'];
$item['supplier_name'] = Supplier::where('id',$item['supplier_id'])->value('mer_name');
})->toArray();
}
/**
* @notes 获取采购供应链商户报价数量
* @return int
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function count(): int
{
return OpurchaseGoodsOffer::where($this->searchWhere)->count();
}
}

View File

@ -92,28 +92,21 @@ class OpurchaseclassLogic extends BaseLogic
*/
public static function detail($params): array
{
$id=$params['id'];
$data = Opurchaseclass::findOrEmpty($params['id'])->toArray();
if ($data) {
$data['goods_info'] = Opurchaseinfo::where('pid', $params['id'])->limit(25)->select()->each(function ($item) {
$data['goods_info'] = Opurchaseinfo::where('pid', $params['id'])->limit(25)->select()->each(function ($item)use($id) {
$find = Goods::where('id', $item['goods'])->with('unitName')->find();
if ($find) {
$item['goods_name'] = $find['name'];
$item['unit_name'] = $find['unit_name'];
}
// $sys_labels = Goods::where('id', $item['goods'])->value('sys_labels');
// $supplier_arr=[];
// if($sys_labels){
// $arr = explode(',', $sys_labels);
// foreach ($arr as $k => $v) {
// if($v>0){
// $supplier=Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->find();
// if($supplier){
// $supplier_arr[]=$supplier;
// }
// }
// }
// }
// $item['supplier'] = array_unique($supplier_arr);
$where=[
'goods_id'=>$item['goods'],
'order_id'=>$id,
'is_adopt'=>1
];
$item['nums_count']=OpurchaseGoodsOffer::where($where)->sum('nums');
});
$data['merchant_name'] = Merchant::where('mer_id', $data['merchant'])->value('mer_name');
@ -198,11 +191,27 @@ class OpurchaseclassLogic extends BaseLogic
* @return bool
* @date 2024/04/27 11:26
*/
public static function goodsOfferUpdate($params)
public static function goodsOfferUpdate($id,$type=0,$notes='',$nums=0)
{
try {
OpurchaseGoodsOffer::where('id', $params)->update(['is_adopt' => 2]);
return true;
$find=OpurchaseGoodsOffer::where('id', $id)->find();
if($type==0){
if($find &&$find['price']==0){
self::setError('报价未设置');
return false;
}
$find->is_adopt=1;
}else{
$find->is_storage=1;
$find->notes=$notes;
$find->before_nums=$find->nums;
$find->nums=$nums;
}
$res= $find->save();
if($res){
return true;
}
return false;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;

View File

@ -95,18 +95,18 @@ class RetailOrderController extends BaseApiController
$order = OrderLogic::createOrder($cartId, $addressId, null, $params);
if ($order != false) {
switch ($pay_type) {
case PayEnum::WECHAT_PAY:
case PayEnum::BALANCE_PAY:
//余额支付
$user = User::where('id', $this->request->userId)->find();
$res = RetailOrderLogic::payBalance($user, $order);
if (RetailOrderLogic::hasError()) {
return $this->fail(RetailOrderLogic::getError());
} else {
$res = RetailOrderLogic::paySuccess($order, ['money' => $order['actual']]);
if (RetailOrderLogic::hasError()) {
} else {
return $this->fail(RetailOrderLogic::getError());
}
} else {
return $this->fail(RetailOrderLogic::getError());
return $this->success('余额支付成功');
}
break;
case PayEnum::WECHAT_PAY:

View File

@ -74,7 +74,9 @@ class OrderLogic extends BaseLogic
static public function createOrder($cartId, $addressId, $user = null, $params = [])
{
$orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params);
if(!$orderInfo){
return false;
}
$_order = $orderInfo['order'];
$_order['deduction_price'] = 0;
$_order['merchant'] = $params['mer_id'];

View File

@ -23,7 +23,7 @@ return [
// 断线重连
'break_reconnect' => true,
// 关闭SQL监听日志
'trigger_sql' => true,
'trigger_sql' => false,
// 自定义分页类
'bootstrap' => ''
],