更新
This commit is contained in:
parent
7007f1ee5a
commit
720a1eb32a
@ -30,7 +30,7 @@ class GoodsLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$sys_labels='';
|
||||
if($params['sys_labels']){
|
||||
if(isset($params['sys_labels'])){
|
||||
$sys_labels=explode(',',$params['sys_labels']);
|
||||
$sys_labels= ','.implode(',',$sys_labels).',';
|
||||
}
|
||||
@ -79,7 +79,7 @@ class GoodsLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$sys_labels='';
|
||||
if($params['sys_labels']){
|
||||
if(isset($params['sys_labels'])){
|
||||
$sys_labels=explode(',',$params['sys_labels']);
|
||||
$sys_labels= ','.implode(',',$sys_labels).',';
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use think\facade\Db;
|
||||
class OpurchaseclassLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
/**
|
||||
* @notes 获取购货订单购物车商品信息
|
||||
* @param $params
|
||||
* @return array
|
||||
@ -32,7 +32,7 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
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');
|
||||
|
||||
$cart_arr = [];
|
||||
@ -42,7 +42,7 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
self::setError('没有购物车信息');
|
||||
return false;
|
||||
}
|
||||
$arr = explode(',',$v['cart_id']);
|
||||
$arr = explode(',', $v['cart_id']);
|
||||
foreach ($arr as $kk => $vv) {
|
||||
$cart_arr[] = $vv;
|
||||
}
|
||||
@ -71,7 +71,7 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
];
|
||||
return ['order' => $order, 'cart_list' => $cart_select];
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* 创建购货订单
|
||||
* @return Object|bool
|
||||
*/
|
||||
@ -119,22 +119,21 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$id=$params['id'];
|
||||
$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)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();
|
||||
if ($find) {
|
||||
$item['goods_name'] = $find['name'];
|
||||
$item['unit_name'] = $find['unit_name'];
|
||||
}
|
||||
$where=[
|
||||
'goods_id'=>$item['goods'],
|
||||
'order_id'=>$id,
|
||||
'is_adopt'=>1
|
||||
$where = [
|
||||
'goods_id' => $item['goods'],
|
||||
'order_id' => $id,
|
||||
'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');
|
||||
}
|
||||
@ -147,9 +146,9 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
* @author likeadmin
|
||||
* @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');
|
||||
$data = [];
|
||||
if ($order_arr) {
|
||||
@ -166,7 +165,7 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
$data['page_no'] = $page_no;
|
||||
$data['page_siz'] = 15;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$order_arr = Opurchaseclass::where('id', $id)->where('is_mer', $is_mer)->value('order_arr');
|
||||
$data = [];
|
||||
if ($order_arr) {
|
||||
@ -196,35 +195,36 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
public static function createSupplierGoods($goods)
|
||||
{
|
||||
try {
|
||||
$sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels');
|
||||
$supplier_arr = [];
|
||||
$goods_offer = [];
|
||||
$sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels');
|
||||
$supplier_arr = [];
|
||||
$goods_offer = [];
|
||||
|
||||
if ($sys_labels) {
|
||||
$sys_labels_arr = explode(',', $sys_labels);
|
||||
foreach ($sys_labels_arr as $k => $v) {
|
||||
if ($v > 0) {
|
||||
$supplier = Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->find();
|
||||
if ($supplier) {
|
||||
$supplier_arr[] = $supplier;
|
||||
}
|
||||
if ($sys_labels) {
|
||||
$sys_labels_arr = explode(',', $sys_labels);
|
||||
foreach ($sys_labels_arr as $k => $v) {
|
||||
if ($v > 0) {
|
||||
$supplier = Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->select();
|
||||
foreach ($supplier as $key => $value) {
|
||||
$supplier_arr[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($supplier_arr as $k => $v) {
|
||||
$goods_offer[] = [
|
||||
'supplier_id' => $v['id'],
|
||||
'goods_id' => $goods['goods'],
|
||||
'price' => 0,
|
||||
'need_num' => $goods['nums']
|
||||
];
|
||||
}
|
||||
if (count($goods_offer)>1) {
|
||||
$res = OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||
if ($res) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($supplier_arr as $k => $v) {
|
||||
$goods_offer[] = [
|
||||
'supplier_id' => $v['id'],
|
||||
'goods_id' => $goods['goods'],
|
||||
'price' => 0,
|
||||
'need_num' => $goods['nums']
|
||||
];
|
||||
}
|
||||
if (count($goods_offer) >= 1) {
|
||||
$res = OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||
if ($res) {
|
||||
Opurchaseinfo::where('id',$goods['id'])->update(['is_push'=>1]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
Log::error('添加采购订单报价失败:' . $e->getMessage());
|
||||
@ -238,24 +238,24 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
* @return bool
|
||||
* @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 {
|
||||
$find=OpurchaseGoodsOffer::where('id', $id)->find();
|
||||
if($type==0){
|
||||
if($find &&$find['price']==0){
|
||||
$find = OpurchaseGoodsOffer::where('id', $id)->find();
|
||||
if ($type == 0) {
|
||||
if ($find && $find['price'] == 0) {
|
||||
self::setError('报价未设置');
|
||||
return false;
|
||||
}
|
||||
$find->is_adopt=2;
|
||||
}else{
|
||||
$find->is_storage=1;
|
||||
$find->notes=$notes;
|
||||
$find->before_nums=$find->nums;
|
||||
$find->nums=$nums;
|
||||
$find->is_adopt = 2;
|
||||
} else {
|
||||
$find->is_storage = 1;
|
||||
$find->notes = $notes;
|
||||
$find->before_nums = $find->nums;
|
||||
$find->nums = $nums;
|
||||
}
|
||||
$res= $find->save();
|
||||
if($res){
|
||||
$res = $find->save();
|
||||
if ($res) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -265,7 +265,7 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @notes 获取订单号
|
||||
* @param $type
|
||||
* @return string
|
||||
|
@ -31,7 +31,7 @@ class SupplierLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$sys_labels='';
|
||||
if($params['sys_labels']){
|
||||
if(isset($params['sys_labels'])){
|
||||
$sys_labels=explode(',',$params['sys_labels']);
|
||||
$sys_labels= ','.implode(',',$sys_labels).',';
|
||||
}
|
||||
@ -147,7 +147,7 @@ class SupplierLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$sys_labels='';
|
||||
if($params['sys_labels']){
|
||||
if(isset($params['sys_labels'])){
|
||||
$sys_labels=explode(',',$params['sys_labels']);
|
||||
$sys_labels= ','.implode(',',$sys_labels).',';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user