This commit is contained in:
mkm 2024-05-18 17:16:18 +08:00
parent 7007f1ee5a
commit 720a1eb32a
3 changed files with 56 additions and 56 deletions

View File

@ -30,7 +30,7 @@ class GoodsLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
$sys_labels=''; $sys_labels='';
if($params['sys_labels']){ if(isset($params['sys_labels'])){
$sys_labels=explode(',',$params['sys_labels']); $sys_labels=explode(',',$params['sys_labels']);
$sys_labels= ','.implode(',',$sys_labels).','; $sys_labels= ','.implode(',',$sys_labels).',';
} }
@ -79,7 +79,7 @@ class GoodsLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
$sys_labels=''; $sys_labels='';
if($params['sys_labels']){ if(isset($params['sys_labels'])){
$sys_labels=explode(',',$params['sys_labels']); $sys_labels=explode(',',$params['sys_labels']);
$sys_labels= ','.implode(',',$sys_labels).','; $sys_labels= ','.implode(',',$sys_labels).',';
} }

View File

@ -24,7 +24,7 @@ use think\facade\Db;
class OpurchaseclassLogic extends BaseLogic class OpurchaseclassLogic extends BaseLogic
{ {
/** /**
* @notes 获取购货订单购物车商品信息 * @notes 获取购货订单购物车商品信息
* @param $params * @param $params
* @return array * @return array
@ -32,7 +32,7 @@ class OpurchaseclassLogic extends BaseLogic
static public function cartIdByPurchaseOrderInfo($params) static public function cartIdByPurchaseOrderInfo($params)
{ {
$where1 = ['paid' => 1,'is_opurchase'=>0,'is_mer'=>1]; $where1 = ['paid' => 1, 'is_opurchase' => 0, 'is_mer' => 1];
$arrs = Opurchaseclass::whereDay('create_time')->where($where1)->column('cart_id,id'); $arrs = Opurchaseclass::whereDay('create_time')->where($where1)->column('cart_id,id');
$cart_arr = []; $cart_arr = [];
@ -42,7 +42,7 @@ class OpurchaseclassLogic extends BaseLogic
self::setError('没有购物车信息'); self::setError('没有购物车信息');
return false; return false;
} }
$arr = explode(',',$v['cart_id']); $arr = explode(',', $v['cart_id']);
foreach ($arr as $kk => $vv) { foreach ($arr as $kk => $vv) {
$cart_arr[] = $vv; $cart_arr[] = $vv;
} }
@ -71,7 +71,7 @@ class OpurchaseclassLogic extends BaseLogic
]; ];
return ['order' => $order, 'cart_list' => $cart_select]; return ['order' => $order, 'cart_list' => $cart_select];
} }
/** /**
* 创建购货订单 * 创建购货订单
* @return Object|bool * @return Object|bool
*/ */
@ -119,22 +119,21 @@ class OpurchaseclassLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$id=$params['id']; $id = $params['id'];
$data = Opurchaseclass::findOrEmpty($params['id'])->toArray(); $data = Opurchaseclass::findOrEmpty($params['id'])->toArray();
if ($data) { if ($data) {
$data['goods_info'] = Opurchaseinfo::where('pid', $params['id'])->limit(25)->select()->each(function ($item)use($id) { $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(); $find = Goods::where('id', $item['goods'])->with('unitName')->find();
if ($find) { if ($find) {
$item['goods_name'] = $find['name']; $item['goods_name'] = $find['name'];
$item['unit_name'] = $find['unit_name']; $item['unit_name'] = $find['unit_name'];
} }
$where=[ $where = [
'goods_id'=>$item['goods'], 'goods_id' => $item['goods'],
'order_id'=>$id, 'order_id' => $id,
'is_adopt'=>1 'is_adopt' => 1
]; ];
$item['nums_count']=OpurchaseGoodsOffer::where($where)->sum('nums'); $item['nums_count'] = OpurchaseGoodsOffer::where($where)->sum('nums');
}); });
$data['merchant_name'] = Merchant::where('mer_id', $data['merchant'])->value('mer_name'); $data['merchant_name'] = Merchant::where('mer_id', $data['merchant'])->value('mer_name');
} }
@ -147,9 +146,9 @@ class OpurchaseclassLogic extends BaseLogic
* @author likeadmin * @author likeadmin
* @date 2024/04/27 11:26 * @date 2024/04/27 11:26
*/ */
public static function sub_detail($id,$is_mer, $page_no): array public static function sub_detail($id, $is_mer, $page_no): array
{ {
if($is_mer==1){ if ($is_mer == 1) {
$order_arr = Opurchaseclass::where('id', $id)->value('order_arr'); $order_arr = Opurchaseclass::where('id', $id)->value('order_arr');
$data = []; $data = [];
if ($order_arr) { if ($order_arr) {
@ -166,7 +165,7 @@ class OpurchaseclassLogic extends BaseLogic
$data['page_no'] = $page_no; $data['page_no'] = $page_no;
$data['page_siz'] = 15; $data['page_siz'] = 15;
} }
}else{ } else {
$order_arr = Opurchaseclass::where('id', $id)->where('is_mer', $is_mer)->value('order_arr'); $order_arr = Opurchaseclass::where('id', $id)->where('is_mer', $is_mer)->value('order_arr');
$data = []; $data = [];
if ($order_arr) { if ($order_arr) {
@ -196,35 +195,36 @@ class OpurchaseclassLogic extends BaseLogic
public static function createSupplierGoods($goods) public static function createSupplierGoods($goods)
{ {
try { try {
$sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels'); $sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels');
$supplier_arr = []; $supplier_arr = [];
$goods_offer = []; $goods_offer = [];
if ($sys_labels) { if ($sys_labels) {
$sys_labels_arr = explode(',', $sys_labels); $sys_labels_arr = explode(',', $sys_labels);
foreach ($sys_labels_arr as $k => $v) { foreach ($sys_labels_arr as $k => $v) {
if ($v > 0) { if ($v > 0) {
$supplier = Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->find(); $supplier = Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->select();
if ($supplier) { foreach ($supplier as $key => $value) {
$supplier_arr[] = $supplier; $supplier_arr[] = $value;
}
} }
} }
} }
foreach ($supplier_arr as $k => $v) { }
$goods_offer[] = [ foreach ($supplier_arr as $k => $v) {
'supplier_id' => $v['id'], $goods_offer[] = [
'goods_id' => $goods['goods'], 'supplier_id' => $v['id'],
'price' => 0, 'goods_id' => $goods['goods'],
'need_num' => $goods['nums'] 'price' => 0,
]; 'need_num' => $goods['nums']
} ];
if (count($goods_offer)>1) { }
$res = OpurchaseGoodsOffer::insertAll($goods_offer); if (count($goods_offer) >= 1) {
if ($res) { $res = OpurchaseGoodsOffer::insertAll($goods_offer);
return true; if ($res) {
} Opurchaseinfo::where('id',$goods['id'])->update(['is_push'=>1]);
return true;
} }
}
} catch (\Exception $e) { } catch (\Exception $e) {
self::setError($e->getMessage()); self::setError($e->getMessage());
Log::error('添加采购订单报价失败:' . $e->getMessage()); Log::error('添加采购订单报价失败:' . $e->getMessage());
@ -238,24 +238,24 @@ class OpurchaseclassLogic extends BaseLogic
* @return bool * @return bool
* @date 2024/04/27 11:26 * @date 2024/04/27 11:26
*/ */
public static function goodsOfferUpdate($id,$type=0,$notes='',$nums=0) public static function goodsOfferUpdate($id, $type = 0, $notes = '', $nums = 0)
{ {
try { try {
$find=OpurchaseGoodsOffer::where('id', $id)->find(); $find = OpurchaseGoodsOffer::where('id', $id)->find();
if($type==0){ if ($type == 0) {
if($find &&$find['price']==0){ if ($find && $find['price'] == 0) {
self::setError('报价未设置'); self::setError('报价未设置');
return false; return false;
} }
$find->is_adopt=2; $find->is_adopt = 2;
}else{ } else {
$find->is_storage=1; $find->is_storage = 1;
$find->notes=$notes; $find->notes = $notes;
$find->before_nums=$find->nums; $find->before_nums = $find->nums;
$find->nums=$nums; $find->nums = $nums;
} }
$res= $find->save(); $res = $find->save();
if($res){ if ($res) {
return true; return true;
} }
return false; return false;
@ -265,7 +265,7 @@ class OpurchaseclassLogic extends BaseLogic
} }
} }
/** /**
* @notes 获取订单号 * @notes 获取订单号
* @param $type * @param $type
* @return string * @return string

View File

@ -31,7 +31,7 @@ class SupplierLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
$sys_labels=''; $sys_labels='';
if($params['sys_labels']){ if(isset($params['sys_labels'])){
$sys_labels=explode(',',$params['sys_labels']); $sys_labels=explode(',',$params['sys_labels']);
$sys_labels= ','.implode(',',$sys_labels).','; $sys_labels= ','.implode(',',$sys_labels).',';
} }
@ -147,7 +147,7 @@ class SupplierLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
$sys_labels=''; $sys_labels='';
if($params['sys_labels']){ if(isset($params['sys_labels'])){
$sys_labels=explode(',',$params['sys_labels']); $sys_labels=explode(',',$params['sys_labels']);
$sys_labels= ','.implode(',',$sys_labels).','; $sys_labels= ','.implode(',',$sys_labels).',';
} }