2024-04-29 16:36:12 +08:00
|
|
|
<?php
|
|
|
|
namespace app\api\logic\operation;
|
|
|
|
use app\common\logic\BaseLogic;
|
|
|
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
2024-05-08 16:42:07 +08:00
|
|
|
use think\facade\Db;
|
2024-04-29 16:36:12 +08:00
|
|
|
|
|
|
|
class OpurchaseGoodsOfferLogic extends BaseLogic{
|
2024-05-08 16:42:07 +08:00
|
|
|
|
2024-04-29 16:36:12 +08:00
|
|
|
|
2024-05-08 16:42:07 +08:00
|
|
|
public static function offer($params): bool
|
|
|
|
{
|
|
|
|
Db::startTrans();
|
|
|
|
try {
|
|
|
|
foreach ($params['data'] as $v){
|
|
|
|
OpurchaseGoodsOffer::where('id',$v['id'])->update([
|
|
|
|
'price' => $v['price'],
|
2024-05-08 18:24:41 +08:00
|
|
|
'nums' => $v['nums'],
|
2024-05-11 17:26:16 +08:00
|
|
|
'is_adopt' => 1,
|
2024-05-08 16:42:07 +08:00
|
|
|
'update_time' => time()
|
|
|
|
]);
|
|
|
|
}
|
2024-05-25 19:12:42 +08:00
|
|
|
$id=$params['data'][0]['id']??0;
|
|
|
|
if($id){
|
|
|
|
$find=OpurchaseGoodsOffer::where('id',$params['data'][0]['id'])->field('supplier_id','create_time')->find();
|
|
|
|
if($find){
|
|
|
|
$time=date('Y-m-d',$find['create_time']);
|
|
|
|
Db::name('opurchase_goods_offer_date')->where('supplier_id', $find['supplier_id'])->whereDay('create_time',$time)->update(['status'=>1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-08 16:42:07 +08:00
|
|
|
Db::commit();
|
|
|
|
return true;
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
Db::rollback();
|
|
|
|
self::setError($e->getMessage());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2024-04-29 16:36:12 +08:00
|
|
|
}
|