$params['id']])->findOrEmpty(); if ($order->isEmpty()) { throw new \Exception('订单不存在'); } $goods = Goods::where(['id' => $params['goods_id']])->findOrEmpty(); if ($goods->isEmpty()) { throw new \Exception('商品不存在'); } //多语言替换 $data = UtilsService::get_langs_data($goods['langs'],$order['lang']); $goods['title'] = $data['title']; //查询会员等级 //查询会员等级 $member_id = UtilsService::get_user_member_id($order['user_id']); $member = UserMember::where(['id' => $member_id])->findOrEmpty(); //数量 $num = $params['num']; //计算佣金 $commission = round($goods['money'] * $num * $member['commission']/100,2); GoodsRecord::update([ 'id' => $params['id'], 'goods_id' => $goods['id'], 'goods_title' => $goods['title'], 'goods_image' => FileService::setFileUrl($goods['image']) , 'unit_price' => $goods['money'], 'num' => $num, 'money' => $goods['money'] * $num, 'commission' => $commission, 'status' => 4 ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } }